답안 #394757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394757 2021-04-27T09:31:39 Z Hossein8320 Network (BOI15_net) C++17
100 / 100
492 ms 47656 KB
//That's what she said
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int maxn = 5e5 + 9, modn = 1e9 + 7;
int n, m, v, u;
vector <int> barg, adj[maxn];
void dfs(int v, int par)
{
    if(adj[v].size() == 1) barg.pb(v);
    for(auto i : adj[v]) if(i != par) dfs(i, v);
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i < n; i++) cin >> v >> u, adj[v].pb(u), adj[u].pb(v);
	dfs(1, 1);
	cout << (barg.size() + 1) / 2 << '\n';
	int s = barg.size() / 2;
	for(int i = 0; i < s; i++) cout << barg[i] << " " << barg[i + s] << '\n';
    if(s != (barg.size() + 1) / 2) cout << barg[2 * s] << " " << barg[0] << '\n';
	return 0;
}

Compilation message

net.cpp: In function 'int32_t main()':
net.cpp:25:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     if(s != (barg.size() + 1) / 2) cout << barg[2 * s] << " " << barg[0] << '\n';
      |        ~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 9 ms 11980 KB Output is correct
3 Correct 7 ms 11980 KB Output is correct
4 Correct 8 ms 11984 KB Output is correct
5 Correct 7 ms 11980 KB Output is correct
6 Correct 9 ms 11980 KB Output is correct
7 Correct 8 ms 11980 KB Output is correct
8 Correct 8 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 8 ms 12060 KB Output is correct
11 Correct 8 ms 12060 KB Output is correct
12 Correct 7 ms 12060 KB Output is correct
13 Correct 8 ms 11980 KB Output is correct
14 Correct 8 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 8 ms 11992 KB Output is correct
17 Correct 8 ms 12040 KB Output is correct
18 Correct 9 ms 11980 KB Output is correct
19 Correct 9 ms 12064 KB Output is correct
20 Correct 8 ms 11980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 9 ms 11980 KB Output is correct
3 Correct 7 ms 11980 KB Output is correct
4 Correct 8 ms 11984 KB Output is correct
5 Correct 7 ms 11980 KB Output is correct
6 Correct 9 ms 11980 KB Output is correct
7 Correct 8 ms 11980 KB Output is correct
8 Correct 8 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 8 ms 12060 KB Output is correct
11 Correct 8 ms 12060 KB Output is correct
12 Correct 7 ms 12060 KB Output is correct
13 Correct 8 ms 11980 KB Output is correct
14 Correct 8 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 8 ms 11992 KB Output is correct
17 Correct 8 ms 12040 KB Output is correct
18 Correct 9 ms 11980 KB Output is correct
19 Correct 9 ms 12064 KB Output is correct
20 Correct 8 ms 11980 KB Output is correct
21 Correct 7 ms 11980 KB Output is correct
22 Correct 8 ms 12108 KB Output is correct
23 Correct 8 ms 12200 KB Output is correct
24 Correct 8 ms 12108 KB Output is correct
25 Correct 10 ms 12180 KB Output is correct
26 Correct 8 ms 12132 KB Output is correct
27 Correct 9 ms 12108 KB Output is correct
28 Correct 9 ms 12108 KB Output is correct
29 Correct 8 ms 12076 KB Output is correct
30 Correct 9 ms 11984 KB Output is correct
31 Correct 9 ms 12068 KB Output is correct
32 Correct 8 ms 11980 KB Output is correct
33 Correct 8 ms 11960 KB Output is correct
34 Correct 8 ms 12064 KB Output is correct
35 Correct 8 ms 12040 KB Output is correct
36 Correct 7 ms 11980 KB Output is correct
37 Correct 8 ms 11980 KB Output is correct
38 Correct 8 ms 12060 KB Output is correct
39 Correct 8 ms 11980 KB Output is correct
40 Correct 8 ms 11980 KB Output is correct
41 Correct 8 ms 11980 KB Output is correct
42 Correct 8 ms 11980 KB Output is correct
43 Correct 8 ms 12108 KB Output is correct
44 Correct 8 ms 12064 KB Output is correct
45 Correct 8 ms 12064 KB Output is correct
46 Correct 8 ms 12108 KB Output is correct
47 Correct 8 ms 11980 KB Output is correct
48 Correct 8 ms 12060 KB Output is correct
49 Correct 8 ms 12064 KB Output is correct
50 Correct 8 ms 11980 KB Output is correct
51 Correct 8 ms 11980 KB Output is correct
52 Correct 8 ms 11980 KB Output is correct
53 Correct 8 ms 12108 KB Output is correct
54 Correct 8 ms 11980 KB Output is correct
55 Correct 8 ms 12056 KB Output is correct
56 Correct 8 ms 11976 KB Output is correct
57 Correct 9 ms 12068 KB Output is correct
58 Correct 9 ms 12108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 9 ms 11980 KB Output is correct
3 Correct 7 ms 11980 KB Output is correct
4 Correct 8 ms 11984 KB Output is correct
5 Correct 7 ms 11980 KB Output is correct
6 Correct 9 ms 11980 KB Output is correct
7 Correct 8 ms 11980 KB Output is correct
8 Correct 8 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 8 ms 12060 KB Output is correct
11 Correct 8 ms 12060 KB Output is correct
12 Correct 7 ms 12060 KB Output is correct
13 Correct 8 ms 11980 KB Output is correct
14 Correct 8 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 8 ms 11992 KB Output is correct
17 Correct 8 ms 12040 KB Output is correct
18 Correct 9 ms 11980 KB Output is correct
19 Correct 9 ms 12064 KB Output is correct
20 Correct 8 ms 11980 KB Output is correct
21 Correct 7 ms 11980 KB Output is correct
22 Correct 8 ms 12108 KB Output is correct
23 Correct 8 ms 12200 KB Output is correct
24 Correct 8 ms 12108 KB Output is correct
25 Correct 10 ms 12180 KB Output is correct
26 Correct 8 ms 12132 KB Output is correct
27 Correct 9 ms 12108 KB Output is correct
28 Correct 9 ms 12108 KB Output is correct
29 Correct 8 ms 12076 KB Output is correct
30 Correct 9 ms 11984 KB Output is correct
31 Correct 9 ms 12068 KB Output is correct
32 Correct 8 ms 11980 KB Output is correct
33 Correct 8 ms 11960 KB Output is correct
34 Correct 8 ms 12064 KB Output is correct
35 Correct 8 ms 12040 KB Output is correct
36 Correct 7 ms 11980 KB Output is correct
37 Correct 8 ms 11980 KB Output is correct
38 Correct 8 ms 12060 KB Output is correct
39 Correct 8 ms 11980 KB Output is correct
40 Correct 8 ms 11980 KB Output is correct
41 Correct 8 ms 11980 KB Output is correct
42 Correct 8 ms 11980 KB Output is correct
43 Correct 8 ms 12108 KB Output is correct
44 Correct 8 ms 12064 KB Output is correct
45 Correct 8 ms 12064 KB Output is correct
46 Correct 8 ms 12108 KB Output is correct
47 Correct 8 ms 11980 KB Output is correct
48 Correct 8 ms 12060 KB Output is correct
49 Correct 8 ms 12064 KB Output is correct
50 Correct 8 ms 11980 KB Output is correct
51 Correct 8 ms 11980 KB Output is correct
52 Correct 8 ms 11980 KB Output is correct
53 Correct 8 ms 12108 KB Output is correct
54 Correct 8 ms 11980 KB Output is correct
55 Correct 8 ms 12056 KB Output is correct
56 Correct 8 ms 11976 KB Output is correct
57 Correct 9 ms 12068 KB Output is correct
58 Correct 9 ms 12108 KB Output is correct
59 Correct 352 ms 36108 KB Output is correct
60 Correct 446 ms 38184 KB Output is correct
61 Correct 8 ms 11980 KB Output is correct
62 Correct 8 ms 11992 KB Output is correct
63 Correct 342 ms 32812 KB Output is correct
64 Correct 10 ms 12492 KB Output is correct
65 Correct 19 ms 14144 KB Output is correct
66 Correct 150 ms 29716 KB Output is correct
67 Correct 488 ms 45892 KB Output is correct
68 Correct 491 ms 47656 KB Output is correct
69 Correct 14 ms 13092 KB Output is correct
70 Correct 88 ms 22412 KB Output is correct
71 Correct 322 ms 40484 KB Output is correct
72 Correct 374 ms 39472 KB Output is correct
73 Correct 116 ms 19260 KB Output is correct
74 Correct 448 ms 36036 KB Output is correct
75 Correct 32 ms 15640 KB Output is correct
76 Correct 335 ms 40108 KB Output is correct
77 Correct 319 ms 40468 KB Output is correct
78 Correct 33 ms 15920 KB Output is correct
79 Correct 492 ms 43508 KB Output is correct
80 Correct 10 ms 12236 KB Output is correct
81 Correct 104 ms 21612 KB Output is correct
82 Correct 392 ms 38284 KB Output is correct
83 Correct 428 ms 36092 KB Output is correct
84 Correct 433 ms 36156 KB Output is correct
85 Correct 429 ms 36124 KB Output is correct
86 Correct 422 ms 38440 KB Output is correct
87 Correct 441 ms 38320 KB Output is correct