# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
553371 | new_acc | Network (BOI15_net) | C++14 | 673 ms | 63756 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 fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
vi graf[N],l;
void dfs(int v,int o){
for(auto u:graf[v]){
if(u==o) continue;
dfs(u,v);
}
if(graf[v].size()==1) l.push_back(v);
}
void solve(){
int n;
cin>>n;
for(int a,b,i=1;i<n;i++){
cin>>a>>b;
graf[a].push_back(b),graf[b].push_back(a);
}
dfs(1,1);
cout<<((l.size()+1)>>1)<<"\n";
for(int i=0;i<(l.size())>>1;i++) cout<<l[i]<<" "<<l[i+(l.size()>>1)]<<"\n";
if(l.size()&1) cout<<l[l.size()-1]<<" "<<l[l.size()>>1]<<"\n";
}
int main(){
solve();
}
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... |