# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305448 | 2020-09-23T08:19:56 Z | shahriarkhan | Network (BOI15_net) | C++14 | 9 ms | 12032 KB |
#include<bits/stdc++.h> using namespace std ; const int siz = 5e5 + 69 ; vector<int> adj[siz] , ar ; void dfs(int s , int p) { if(adj[s].size()==1) ar.push_back(s) ; for(int t : adj[s]) { if(t==p) continue ; dfs(t,s) ; } } 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] ; } dfs(1,0) ; int six = ar.size() ; printf("%d\n",(six+1)/2) ; if(six%2) { ar.push_back(ar[0]) ; ++six ; } for(int i = 0 ; i < six ; i += 2) { printf("%d %d\n",ar[i],ar[i+1]) ; } return 0 ; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 12032 KB | Invalid number of links. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 12032 KB | Invalid number of links. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 12032 KB | Invalid number of links. |
2 | Halted | 0 ms | 0 KB | - |