# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
106889 | 2019-04-20T20:23:01 Z | Pajaraja | Network (BOI15_net) | C++17 | 15 ms | 12032 KB |
#include <bits/stdc++.h> using namespace std; int cnt; vector<int> g[500007]; int k[500007]; void dfs(int s,int f) { if(g[s].size()==1) {k[cnt++]=s; return;} for(int i=0;i<g[s].size();i++) if(g[s][i]!=f) dfs(g[s][i],s); } int main() { int n,v1,v2,l=0; scanf("%d",&n); for(int i=0;i<n-1;i++) { scanf("%d%d",&v1,&v2); g[v1].push_back(v2); g[v2].push_back(v1); } for(int i=1;i<=n;i++) if(g[i].size()==1) l++; printf("%d\n",(l+1)/2); for(int i=1;i<=n;i++) if(g[i].size()>1) { dfs(i,0); for(int j=0;j<l/2;j++) printf("%d %d\n",k[j],k[j+l/2]); if(l%2==1) printf("%d %d",i,k[l-1]); return 0; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 12032 KB | Output is correct |
2 | Correct | 12 ms | 12032 KB | Output is correct |
3 | Correct | 15 ms | 12032 KB | Output is correct |
4 | Correct | 13 ms | 12032 KB | Output is correct |
5 | Correct | 14 ms | 12032 KB | Output is correct |
6 | Correct | 13 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 | 13 ms | 12032 KB | Output is correct |
2 | Correct | 12 ms | 12032 KB | Output is correct |
3 | Correct | 15 ms | 12032 KB | Output is correct |
4 | Correct | 13 ms | 12032 KB | Output is correct |
5 | Correct | 14 ms | 12032 KB | Output is correct |
6 | Correct | 13 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 | 13 ms | 12032 KB | Output is correct |
2 | Correct | 12 ms | 12032 KB | Output is correct |
3 | Correct | 15 ms | 12032 KB | Output is correct |
4 | Correct | 13 ms | 12032 KB | Output is correct |
5 | Correct | 14 ms | 12032 KB | Output is correct |
6 | Correct | 13 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 | - |