# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
764780 | vjudge1 | Network (BOI15_net) | C++11 | 2 ms | 628 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(){
long long int n,a,b,cnt=0,sum,hr=0;
cin>>n;
vector <long long int> vec(n+1,0);
vector <long long int> sa;
for(int i=1;i<n;i++){
cin>>a>>b;
vec[a]++;
vec[b]++;
// cout<<i<<endl;
}
bool bo=0;
for(int i=1;i<=n;i++){
if(vec[i]<2){
cnt++;
sa.push_back(i);
// cout<<i<<endl;
}
else if(bo==0){
sum=i;
bo=1;
}
}
cout<<round(double(cnt)/2)/*<<"()"<<cnt*/<<endl;
if(cnt%2!=0){
hr=cnt;
cnt=(cnt-1);
}
for(int i=1;i<=cnt;i++){
if(i%2!=0){
cout<<sa[i-1]<<" ";
}
else{
cout<<sa[i-1]<<endl;
}
}
if(hr%2!=0){
cout<<sa[sa.size()-1]<<" "<<sum;
}
system("pause");
}
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... |