10935 | 2024-04-20 16:28:14 | k_balint | Vasútépítés | cpp17 | Wrong answer 0/100 | 90ms | 16136 KiB |
#include <bits/stdc++.h>
using namespace std;
const int c=1005;
int n,m,tt;
vector<int> adj[c];
int vis[c];
int cnt,deg;
vector<int> kor;
bool van;
int ans[c][c];
int par[c];
void dfs(int v){
++cnt; deg+=adj[v].size();
vis[v]=1;
for(int x:adj[v]){
if(!vis[x]) dfs(x);
}
}
void dfs2(int v, int p){
if(van) return;
vis[v]=2;
par[v]=p;
for(int x:adj[v]){
if(van) break;
if(x==p) continue;
if(vis[x]==1) dfs2(x,v);
else if(!van){
int k=v;
while(k != par[x]){
kor.push_back(k);
k=par[k];
}
van=1;
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=1;i<=m;i++){
int a,b; cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
// for(int i=1;i<=n;i++){
// if(!vis[i]){
// deg=0; cnt=0;
// dfs(i);
// if(deg>2*cnt){
// cout << -1 << endl;
// return 0;
// }
// kor.clear();
// van=0;
// dfs2(i,0);
// for(int j=0;j<kor.size();j++){
// int x=kor[(j+1)%kor.size()];
// int y=kor[j];
// ans[x][y]=ans[y][x]=++tt;
// }
// }
// }
for(int i=1;i<=n;i++){
for(int x:adj[i]){
if(!ans[x][i]){
ans[x][i]=ans[i][x]=++tt;
}
}
}
for(int i=1;i<n;i++){
for(int j=i+1;j<=n;j++){
if(!ans[i][j]) ans[i][j]=++tt;
cout << ans[i][j] << ' ';
}
cout << '\n';
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 2224 KiB | ||||
2 | Wrong answer | 3ms | 2400 KiB | ||||
3 | Wrong answer | 3ms | 3156 KiB | ||||
subtask2 | 0/40 | ||||||
4 | Wrong answer | 46ms | 10544 KiB | ||||
5 | Wrong answer | 46ms | 10724 KiB | ||||
6 | Wrong answer | 46ms | 10936 KiB | ||||
7 | Wrong answer | 46ms | 11144 KiB | ||||
8 | Wrong answer | 46ms | 11120 KiB | ||||
9 | Wrong answer | 46ms | 11132 KiB | ||||
10 | Wrong answer | 46ms | 11136 KiB | ||||
11 | Accepted | 3ms | 3172 KiB | ||||
subtask3 | 0/60 | ||||||
12 | Wrong answer | 46ms | 10544 KiB | ||||
13 | Wrong answer | 46ms | 10724 KiB | ||||
14 | Wrong answer | 46ms | 10936 KiB | ||||
15 | Wrong answer | 46ms | 11144 KiB | ||||
16 | Wrong answer | 46ms | 11120 KiB | ||||
17 | Wrong answer | 46ms | 11132 KiB | ||||
18 | Wrong answer | 46ms | 11136 KiB | ||||
19 | Accepted | 3ms | 3172 KiB | ||||
20 | Wrong answer | 46ms | 11152 KiB | ||||
21 | Wrong answer | 48ms | 11096 KiB | ||||
22 | Wrong answer | 46ms | 11364 KiB | ||||
23 | Wrong answer | 46ms | 11440 KiB | ||||
24 | Wrong answer | 46ms | 11336 KiB | ||||
25 | Wrong answer | 46ms | 11464 KiB | ||||
26 | Wrong answer | 46ms | 11560 KiB | ||||
27 | Wrong answer | 46ms | 11580 KiB | ||||
28 | Wrong answer | 90ms | 16136 KiB | ||||
29 | Wrong answer | 46ms | 11580 KiB | ||||
30 | Wrong answer | 46ms | 11592 KiB | ||||
31 | Wrong answer | 46ms | 11584 KiB |