#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5;
int deg[MAXN];
int sub[MAXN];
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, m; cin >> n >> m;
n += m;
for (int i = 0; i < n-1; i++) {
int x, y; cin >> x >> y;
deg[x-1]++;
deg[y-1]++;
}
for (int i = 0; i < n; i++) {
sub[deg[i]]++;
}
int num = n;
for (int i = 1; i < n; i++) {
num -= sub[i];
if (num) cout << i << " " << num << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
324 KB |
Output is correct |
3 |
Correct |
55 ms |
4856 KB |
Output is correct |
4 |
Correct |
58 ms |
5324 KB |
Output is correct |
5 |
Correct |
15 ms |
1240 KB |
Output is correct |
6 |
Correct |
58 ms |
5440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
0 ms |
324 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
324 KB |
Output is correct |
3 |
Correct |
55 ms |
4856 KB |
Output is correct |
4 |
Correct |
58 ms |
5324 KB |
Output is correct |
5 |
Correct |
15 ms |
1240 KB |
Output is correct |
6 |
Correct |
58 ms |
5440 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
328 KB |
Output is correct |
23 |
Correct |
0 ms |
324 KB |
Output is correct |
24 |
Correct |
1 ms |
328 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
3 ms |
468 KB |
Output is correct |
27 |
Correct |
59 ms |
5180 KB |
Output is correct |
28 |
Correct |
61 ms |
5324 KB |
Output is correct |
29 |
Correct |
20 ms |
2320 KB |
Output is correct |
30 |
Correct |
35 ms |
3632 KB |
Output is correct |
31 |
Correct |
5 ms |
852 KB |
Output is correct |
32 |
Correct |
4 ms |
596 KB |
Output is correct |
33 |
Correct |
32 ms |
3336 KB |
Output is correct |
34 |
Correct |
29 ms |
3160 KB |
Output is correct |
35 |
Correct |
32 ms |
3664 KB |
Output is correct |
36 |
Correct |
32 ms |
3652 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |