제출 #1058673

#제출 시각아이디문제언어결과실행 시간메모리
1058673kachim2Make them Meet (EGOI24_makethemmeet)C++17
57 / 100
4 ms856 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){ 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); } 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...