# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
939078 | ezzzay | Network (BOI15_net) | C++14 | 650 ms | 58084 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 int long long
#define ff first
#define ss second
#define pb push_back
const int N=5e5+5;
bool vis[N];
vector<int>v[N];
vector<pair<int,int>>rts;
vector<int>vec;
void dfs(int a, int p=-1){
if(v[a].size()==1)vec.pb(a);
for(auto b:v[a]){
if(b!=p){
dfs(b,a);
}
}
}
signed main(){
int n;
cin>>n;
for(int i=1;i<n;i++){
int a,b;
cin>>a>>b;
v[a].pb(b);
v[b].pb(a);
rts.pb({a,b});
}
dfs(1);
cout<<vec.size()/2+vec.size()%2<<endl;
for(int i=0;i<(vec.size()+1)/2;i++){
cout<<vec[i]<<" "<<vec[i+vec.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... |