# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
220847 | 2020-04-09T05:08:12 Z | arnold518 | Network (BOI15_net) | C++14 | 13 ms | 12032 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5e5; const int INF = 987654321; int N; vector<int> adj[MAXN+10], V; void dfs(int now, int bef) { int cnt=0; for(int nxt : adj[now]) { if(nxt==bef) continue; dfs(nxt, now); cnt++; } if(cnt==0) V.push_back(now); } int main() { int i, j; scanf("%d", &N); for(i=1; i<N; i++) { int u, v; scanf("%d%d", &u, &v); adj[u].push_back(v); adj[v].push_back(u); } for(i=1; i<=N; i++) if(adj[i].size()>1) break; int root=i; dfs(root, root); printf("%d\n", (V.size()+1)/2); for(i=0; i<V.size()/2; i++) printf("%d %d\n", V[i], V[i+V.size()/2]); if(V.size()%2) printf("%d %d\n", root, V.back()); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12032 KB | Output is correct |
2 | Correct | 12 ms | 12032 KB | Output is correct |
3 | Correct | 12 ms | 12032 KB | Output is correct |
4 | Correct | 11 ms | 12032 KB | Output is correct |
5 | Correct | 12 ms | 12032 KB | Output is correct |
6 | Correct | 12 ms | 12032 KB | Output is correct |
7 | Incorrect | 13 ms | 12032 KB | Breaking single line is causing network to disconnect. |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12032 KB | Output is correct |
2 | Correct | 12 ms | 12032 KB | Output is correct |
3 | Correct | 12 ms | 12032 KB | Output is correct |
4 | Correct | 11 ms | 12032 KB | Output is correct |
5 | Correct | 12 ms | 12032 KB | Output is correct |
6 | Correct | 12 ms | 12032 KB | Output is correct |
7 | Incorrect | 13 ms | 12032 KB | Breaking single line is causing network to disconnect. |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12032 KB | Output is correct |
2 | Correct | 12 ms | 12032 KB | Output is correct |
3 | Correct | 12 ms | 12032 KB | Output is correct |
4 | Correct | 11 ms | 12032 KB | Output is correct |
5 | Correct | 12 ms | 12032 KB | Output is correct |
6 | Correct | 12 ms | 12032 KB | Output is correct |
7 | Incorrect | 13 ms | 12032 KB | Breaking single line is causing network to disconnect. |
8 | Halted | 0 ms | 0 KB | - |