# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
49445 | faishol27 | Network (BOI15_net) | C++14 | 3 ms | 644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define PUB push_back
int N;
int way[500005];
vector<int>leaf;
int main(){
cin >> N;
for(int i = 0;i<N-1;i++){
int x, y;
cin >> x >> y;
way[x]++;
way[y]++;
}
for(int i=1;i<=N;i++) if(way[i]==1) leaf.PUB(i);
if(leaf.size()%2 == 1) leaf.PUB(1);
cout << leaf.size()/2 << endl;
for(int i=0;i<leaf.size();i+=2){
cout << leaf[i] << " " << leaf[i+1] << endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |