# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25878 | 2017-06-24T16:25:42 Z | nibnalin | Network (BOI15_net) | C++14 | 6 ms | 13736 KB |
#include <iostream> #include <cstdio> #include <vector> #include <cmath> using namespace std; const int maxn = int(5e5)+5; vector<int> graph[maxn], S; void dfs(int node, int par) { if(int(graph[node].size()) == 1) S.push_back(node); for(auto it: graph[node]) { if(it != par) dfs(it, node); } } int main(void) { int n, u, v; scanf("%d", &n); for(int i = 1;i < n;i++) { scanf("%d%d", &u, &v); u--, v--; graph[u].push_back(v), graph[v].push_back(u); } dfs(0, -1); int res = ceil(int(S.size())/2.0); printf("%d\n", res); for(int i = 0;i < res;i++) { printf("%d %d\n", S[i]+1, S[max((res+i), int(S.size())-1)]+1); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13736 KB | Output is correct |
2 | Incorrect | 3 ms | 13736 KB | Breaking single line is causing network to disconnect. |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13736 KB | Output is correct |
2 | Incorrect | 3 ms | 13736 KB | Breaking single line is causing network to disconnect. |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13736 KB | Output is correct |
2 | Incorrect | 3 ms | 13736 KB | Breaking single line is causing network to disconnect. |
3 | Halted | 0 ms | 0 KB | - |