제출 #1189051

#제출 시각아이디문제언어결과실행 시간메모리
1189051comxddddddNetwork (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'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...