Submission #1058672

#TimeUsernameProblemLanguageResultExecution timeMemory
1058672kachim2Make them Meet (EGOI24_makethemmeet)C++17
0 / 100
490 ms1048576 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...