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