Submission #1058675

#TimeUsernameProblemLanguageResultExecution timeMemory
1058675kachim2Make them Meet (EGOI24_makethemmeet)C++17
70 / 100
5 ms604 KiB
#include<bits/stdc++.h> using namespace std; vector<vector<int>> graph; int n, m; vector<int> c; vector<bool> visited; void pathlike(){ cout << "600\n"; for(int i = 0; i < 600; i++){ for(int j = 0; j < n; j++){ cout << (j+(i%2))/2 << ' '; } cout << '\n'; } } void dfs(int v, int p, int d){ visited[v]=1; 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); } if(m==(n*(n-1))/2){ pathlike(); return 0; } 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] = graph[root][0]; c[graph[root][0]]=graph[root][0]; 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...