Submission details
Task:Fragile network
Sender:aalto26fw_002
Submission time:2026-10-07 17:00:01 +0300
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.06 sdetails
#2ACCEPTED0.04 sdetails
#30.06 sdetails
#4ACCEPTED0.04 sdetails
#50.06 sdetails
#60.17 sdetails
#7ACCEPTED0.12 sdetails
#80.17 sdetails
#90.14 sdetails
#100.14 sdetails
#11ACCEPTED0.04 sdetails
#120.04 sdetails
#130.04 sdetails
#140.12 sdetails
#150.04 sdetails
#160.04 sdetails
#170.04 sdetails
#180.06 sdetails
#19ACCEPTED0.04 sdetails
#200.06 sdetails
#21ACCEPTED0.04 sdetails

Code

n = int(input())
graph = []
nodes = [0]*(n+1)
for i in range(n-1):
    buffer = input().split()
    a = int(buffer[0])
    b = int(buffer[1])
    nodes[a] += 1
    nodes[b] += 1

res = []
for i in range(1,n+1):
    if nodes[i] == 1:
        res.append(i)

#k = len(res)-1
k = (len(res)+1)//2
print(k)
for j in range(k):
    print(res[2*j],res[2*j+1])

Test details

Test 1

Verdict:

input
10
1 5
1 7
1 8
1 3
...

correct output
5
5 2
7 9
8 6
3 10
...

user output
5
2 3
4 5
6 7
8 9

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 2

Verdict: ACCEPTED

input
10
4 5
3 4
2 3
9 10
...

correct output
1
10 1

user output
1
1 10

Test 3

Verdict:

input
10
1 8
1 3
3 5
5 7
...

correct output
3
7 10
8 2
1 9

user output
3
2 7
8 9

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 4

Verdict: ACCEPTED

input
10
1 5
3 7
2 10
3 8
...

correct output
3
10 8
6 4
5 9

user output
3
4 5
6 8
9 10

Test 5

Verdict:

input
10
4 8
3 4
4 6
2 3
...

correct output
3
8 7
10 9
1 6

user output
3
6 7
8 9

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 6

Verdict:

input
100000
1 56967
1 56618
1 42321
1 82550
...

correct output
50000
56967 16911
56618 39942
42321 99902
82550 2538
...

user output
50000
2 3
4 5
6 7
8 9
...

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 7

Verdict: ACCEPTED

input
100000
92297 92298
23511 23512
68057 68058
65434 65435
...

correct output
1
100000 1

user output
1
1 100000

Test 8

Verdict:

input
100000
17747 97512
10397 12053
679 6975
4013 14565
...

correct output
25057
92881 76094
20353 87429
16069 96487
71186 52809
...

user output
25057
388 577
715 785
837 1166
1220 1261
...

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 9

Verdict:

input
100000
72941 72942
11232 11233
73464 73465
30042 30043
...

correct output
489
16423 85168
20707 94190
36505 54940
96411 44067
...

user output
489
1 99
667 718
884 1400
1404 1453
...

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 10

Verdict:

input
100000
31451 31452
7473 7474
24056 24057
85181 85182
...

correct output
51
25638 2983
87594 87371
92001 50610
46744 100000
...

user output
51
1 140
346 1093
2983 5134
6092 6887
...

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 11

Verdict: ACCEPTED

input
10
1 2
1 3
3 4
3 5
...

correct output
2
2 6
4 10

user output
2
2 4
6 10

Test 12

Verdict:

input
7
1 2
2 3
2 4
1 5
...

correct output
2
4 7
3 6

user output
2
3 4
6 7

Test 13

Verdict:

input
6
1 2
1 3
1 4
4 5
...

correct output
2
3 6
2 5

user output
2
2 3
5 6

Test 14

Verdict:

input
65538
1 2
1 3
1 4
3 5
...

correct output
16385
34 36
40 42
35 41
48 50
...

user output
16385
2 4
33 34
35 36
39 40
...

Test 15

Verdict:

input
11
1 2
1 3
2 4
2 5
...

correct output
2
9 11
8 10

user output
2
8 9
10 11

Test 16

Verdict:

input
7
1 2
1 3
2 4
2 5
...

correct output
2
5 7
4 6

user output
2
4 5
6 7

Test 17

Verdict:

input
7
1 2
1 3
2 4
2 5
...

correct output
2
5 7
4 6

user output
2
4 5
6 7

Test 18

Verdict:

input
10
8 4
3 4
4 6
2 3
...

correct output
3
8 7
10 9
1 6

user output
3
6 7
8 9

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 19

Verdict: ACCEPTED

input
7
1 2
1 5
2 3
2 6
...

correct output
2
6 7
3 4

user output
2
3 4
6 7

Test 20

Verdict:

input
8
1 2
1 3
2 4
2 5
...

correct output
3
4 7
6 8
1 5

user output
3
4 5
6 7

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 20, in <module>
    print(res[2*j],res[2*j+1])
IndexError: list index out of range

Test 21

Verdict: ACCEPTED

input
10
2 1
3 1
4 2
5 4
...

correct output
3
9 8
6 10
3 7

user output
3
3 6
7 8
9 10