Submission #993879

#TimeUsernameProblemLanguageResultExecution timeMemory
993879NexusNetwork (BOI15_net)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const ll N=2e5+9,M=2e18+9,mod=1e9+7; ll n,x,y,z; map<ll,ll>m; vector<ll>v; int main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>n; while(--n) { cin>>x>>y; ++m[x],++m[y]; } for(auto i:m) { if(i.second==1)v.push_back(i.first); } n=v.size(); cout<<n/2+n%2<<'\n'; for(ll i=1;i<n;i+=2)cout<<v[i]<<' '<<v[i-1]<<'\n'; if(n&1)cout<<v[n-1]<<' '<<v[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...