# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
394681 | MahdiBahramian | Network (BOI15_net) | C++17 | 761 ms | 45216 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 pb push_back
using namespace std;
const int Max = 5e5 + 10;
vector<int> N[Max];
vector<int> L;
void DFS(int v , int p = 0)
{
if(N[v].size() == 1) L.pb(v);
for(int u : N[v]) if(u != p) DFS(u , v);
}
int main()
{
int n; cin >> n;
for(int i = 1 , a , b ; i < n ; i++) cin >> a >> b , N[a].pb(b) , N[b].pb(a);
DFS(1);
cout << (L.size() + 1) / 2 << '\n';
for(int i = 0 , j = L.size() / 2 ; j < L.size() ; i++ , j++) cout << L[i] << ' ' << L[j] << '\n';
}
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... |