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;
vector<vector<int>> graph;
int n, m;
vector<int> c;
vector<bool> visited;
void dfs(int v, int p, int d){
if(d%2) c[v] = p;
else c[v] = v;
for(auto i : graph[v]){
if(!visited[i]) dfs(i, v, d+1);
}
}
int main(){
cin >> n >> m;
graph.resize(n);
c.resize(n);
visited.resize(n);
for(int i = 0; i < m; i++){
int x, y;
cin >> x >> y;
graph[x].push_back(y);
graph[y].push_back(x);
}
int root = 0;
for(int i = 0; i < n; i++) if(graph[i].size() == 1) root = i;
cout << "600\n";
for(int i = 0; i < 600; i++){
fill(visited.begin(), visited.end(), 0);
dfs(root, -1, i%2);
c[root] = root;
c[graph[root][0]]=root;
for(auto i : c){
cout << i << ' ';
}
cout << '\n';
}
}
# | 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... |