# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42651 | XmtosX | Network (BOI15_net) | C++14 | 11 ms | 12396 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 n,last;
queue <int> q;
vector <int> v[500005];
int main()
{
scanf("%d",&n);
for (int i=0;i<n-1;i++)
{
int a,b;
scanf("%d%d",&a,&b);
v[a].push_back(b);
v[b].push_back(a);
}
for (int i=1;i<=n;i++)
{
if (v[i].size()==1)
q.push(i);
}
printf("%d\n",q.size()/2+(q.size())%2);
while (q.size()>1)
{
last=q.front();
printf("%d ",q.front());
q.pop();
printf("%d\n",q.front());
q.pop();
}
if (!q.empty())
printf("%d %d\n",q.front(),last);
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... |