# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
102142 | Leonardo_Paes | Network (BOI15_net) | C++11 | 4 ms | 384 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;
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);
}
}
cout << ceil((double)v.size()/2) << endl;
for(int i=0; i<v.size(); i+=2){
if(i==v.size()-1)break;
cout << v[i] << " " << v[i+1] << "\n";
}
if(v.size()%2==1){
cout << v[v.size()-1] << " " << v[v.size()-2] << 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... |