제출 #1098160

#제출 시각아이디문제언어결과실행 시간메모리
1098160Trisanu_DasMake them Meet (EGOI24_makethemmeet)C++17
57 / 100
557 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; int n, m, sink, root, odd[105], even[105]; vector<int> adj[105]; void dfs(int u, int p, int dep){ for(int v : adj[u]){ if(v == p) continue; if(dep & 1) odd[v] = u; else even[v] = u; dfs(v, u, dep + 1); } } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; while(m--){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } for(int i = 0; i < n; i++){ if(adj[i].size() == 1){ sink = i; root = adj[i][0]; break; } } iota(odd, odd + n, 0); iota(even, even + n, 0); odd[sink] = root; dfs(root, -1, 0); cout << 2 * n << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++) cout << even[j] << ' '; cout << '\n'; for(int j = 0; j < n; j++) cout << odd[j] << ' '; 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...