This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<int>> g;
vector<int> vis, depth;
void dfs(int v, int par){
vis[v] = 1;
if (par != -1) depth[v] = depth[par] + 1;
for (int u : g[v]){
if (u != par && vis[u] == 0){
dfs(u, v);
}
}
}
signed main(){
int n, m; cin >> n >> m;
g.clear();
g.resize(n + 1);
vis.clear();
vis.resize(n + 1);
depth.clear();
depth.resize(n + 1);
for (int i = 0; i < m; i++){
int a, b; cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
int root = 0;
/*for (int i = 0; i < n; i++){
if ((long long)(g[i].size()) == 1) {
root = i;
break;
}
}*/
depth[root] = 0;
dfs(root, -1);
cout << 3*10 << endl;
for (int k = 0; k < 10; k++){
for (int i = 0; i < n; i++){
cout << depth[i] / 2 << ' ';
}
cout << endl;
for (int i = 0; i < n; i++){
cout << (depth[i] + 1) / 2 << ' ';
}
cout << endl;
for (int i = 0; i < n; i++){
if (depth[i] <= 1) cout << n << ' ';
else cout << i << ' ';
}
cout << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |