# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434954 | Blobo2_Blobo2 | Network (BOI15_net) | C++14 | 1 ms | 204 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.
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define gen(arr,n,nxt) generate(arr,arr+n,nxt)
#define Blobo2_el_gamded_gedan_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);
const int mo=1e9+7;
int nxt(){int x;cin>>x;return x;}
signed main(){
Blobo2_el_gamded_gedan_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
int n=nxt();
vector<int>adj[n];
for(int i=0;i<n-1;i++){
int x=nxt()-1,y=nxt()-1;
adj[x].push_back(y);
adj[y].push_back(x);
}
vector<int>v;
int cnt=0;
for(int i=0;i<n;i++)
if(adj[i].size()==1)
cnt++,v.push_back(i);
cout<<(cnt+1)/2<<endl;
if(cnt%2==0){
for(int i=0;i<v.size();i+=2)
cout<<v[i]+1<<' '<<v[i+1]+1<<endl;
}
else{
for(int i=0;i<v.size()-1;i+=2)
cout<<v[i]+1<<' '<<v[i+1]+1<<endl;
cout<<v.back()<<' '<<v[v.size()-2]<<endl;
}
return 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... |