# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151230 | cfalas | Network (BOI15_net) | C++14 | 2 ms | 380 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;
int main(){
int n;
vector<int> ans;
cin>>n;
int a[n+1] = {};
for(int i=0;i<=n;i++) a[i]=0;
for(int i=0;i<n-1;i++){
int b, c;
cin>>b>>c;
a[b]++;
a[c]++;
}
for(int i=1;i<=n;i++){
if(a[i]<2) ans.push_back(i);
}
cout<<(ans.size()+1)/2<<endl;
for(int i=0;i<(ans.size()+1)/2;i++){
cout<<ans[i]<<" "<<ans[(i+(ans.size()+1)/2)%ans.size()]<<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... |