Submission #748406

#TimeUsernameProblemLanguageResultExecution timeMemory
748406mariowongNetwork (BOI15_net)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; int deg[100005]; int main(){ ios::sync_with_stdio(false); int n; cin >> n; for (int i=1;i<n;i++){ int u,v; cin >> u >> v; deg[u]++; deg[v]++; } int cnt=0; for (int i=1;i<=n;i++){ if (deg[i] == 1) cnt++; } cout << (cnt+1)/2 << "\n"; int node=0; for (int i=1;i<=n;i++){ if (deg[i] == 1){ if (node == 0) node=i; else{ cout << node << " " << i << "\n"; node=0; } } } for (int i=1;i<=n;i++){ if (deg[i] == 1 && node != 0){ cout << node << " " << i << "\n"; break; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...