# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
588563 | 2022-07-03T14:25:33 Z | M_W | Network (BOI15_net) | C++17 | 1 ms | 308 KB |
#include <bits/stdc++.h> using namespace std; vector<int> v; int deg[500001]; int main(){ int N; scanf("%d", &N); for(int i = 1, u, v; i < N; i++){ scanf("%d %d", &u, &v); deg[u]++; deg[v]++; } for(int i = 1; i <= N; i++){ if(deg[i] == 1) v.push_back(i); } queue<pair<int, int>> q; for(int i = 0; i + 1 < v.size(); i += 2){ q.push({v[i], v[i + 1]}); } if(v.size() % 2) q.push({v[v.size() - 1], 1}); printf("%d\n", q.size()); while(!q.empty()){ printf("%d %d\n", q.front().first, q.front().second); q.pop(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Incorrect | 1 ms | 308 KB | Breaking single line is causing network to disconnect. |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Incorrect | 1 ms | 308 KB | Breaking single line is causing network to disconnect. |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Incorrect | 1 ms | 308 KB | Breaking single line is causing network to disconnect. |
11 | Halted | 0 ms | 0 KB | - |