Submission #102145

#TimeUsernameProblemLanguageResultExecution timeMemory
102145Leonardo_PaesNetwork (BOI15_net)C++11
0 / 100
3 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 100; int grau[MAXN]; int main(){ int n; cin >> n; for(int i=1; i<n; i++){ int a, b; cin >> a >> b; grau[a]++; grau[b]++; } vector<int> v; for(int i=1; i<=n; i++){ if(grau[i]==1){ v.push_back(i); } } int ans = (v.size()+1)/2; cout << ans << "\n"; for(int i=0; i<ans-1; i++){ cout << v[i] << " " << v[i+ans] << "\n"; } if(v.size()&1){ cout << v[ans-1] << " " << v[0] << "\n"; } else{ cout << v[ans-1] << " " << v[v.size()-1]; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...