# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305436 | shahriarkhan | Network (BOI15_net) | C++14 | 1 ms | 384 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 ;
int main()
{
int n ;
scanf("%d",&n) ;
int deg[n+1] = {0} ;
for(int i = 1 ; i < n ; ++i)
{
int u , v ;
scanf("%d%d",&u,&v) ;
++deg[u] , ++deg[v] ;
}
vector<int> ans ;
for(int i = 1 ; i <= n ; ++i)
{
if(deg[i]==1) ans.push_back(i) ;
}
int p = ans.size() ;
printf("%d\n",(p+1)/2) ;
if(p%2)
{
printf("%d %d\n",ans[p-1],ans[p-2]) ;
--p ;
}
for(int i = 0 ; i < p ; i += 2)
{
printf("%d %d\n",ans[i],ans[i+1]) ;
}
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... |