# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
765014 | vjudge1 | Network (BOI15_net) | C++11 | 1 ms | 212 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>
#define pb push_back
using namespace std;
int main()
{
int n;
cin>>n;
bool t[n][n];
memset(t, 0, sizeof t);
for(int i = 0; i<n-1; i++){
int x, y;
cin>>x>>y;
t[x-1][y-1]=1;
t[y-1][x-1]=1;
}
vector<int>one;
for(int i = 0; i<n; i++){
int cnt=0;
for(int j = 0; j<n; j++){
if(t[i][j]==1) cnt++;
if(cnt>=2){
j=n-1;
continue;
}
}
if(cnt<2) one.pb(i+1);
}
int s = one.size()/2+one.size()%2;
cout<<s<<'\n';
for(int i = 0; i<one.size()/2; i++){
cout<<one[i*2]<<' '<<one[i*2+1]<<'\n';
}
if(s%2!=0) cout<<one[one.size()-1]<<' '<<one[0];
}
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... |