Submission #1189057

#TimeUsernameProblemLanguageResultExecution timeMemory
1189057comxddddddNetwork (BOI15_net)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(nullptr); int n,t1,t2; cin >> n; vector<int> net(n + 1,0); vector<int> con; for(int i = 1; i < n; i++){ cin >> t1 >> t2; net[t1]++; net[t2]++; } int c = 0; for(int i = 1; i < net.size(); i++){ if(net[i] == 1){ c++; con.emplace_back(i); } } if(c % 2 == 1){ c /= 2; c += 1; } else{ c /= 2; } cout << c << '\n'; while(con.size() > 1){ t1 = con.back(); con.pop_back(); t2 = con.back(); con.pop_back(); cout << t1 << ' ' << t2 << '\n'; } if(con.size() == 1){ cout << con.back() << ' '; for(int i = 1; i < net.size(); i++){ if(i != con.back()){ cout << i << '\n'; break; } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...