| Task: | Fragile network |
| Sender: | aalto25f_004 |
| Submission time: | 2025-10-08 17:36:39 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | RUNTIME ERROR | 0.07 s | details |
| #3 | ACCEPTED | 0.04 s | details |
| #4 | RUNTIME ERROR | 0.06 s | details |
| #5 | ACCEPTED | 0.04 s | details |
| #6 | ACCEPTED | 0.31 s | details |
| #7 | RUNTIME ERROR | 0.29 s | details |
| #8 | WRONG ANSWER | 0.34 s | details |
| #9 | ACCEPTED | 0.27 s | details |
| #10 | ACCEPTED | 0.27 s | details |
| #11 | RUNTIME ERROR | 0.07 s | details |
| #12 | RUNTIME ERROR | 0.07 s | details |
| #13 | RUNTIME ERROR | 0.06 s | details |
| #14 | RUNTIME ERROR | 0.20 s | details |
| #15 | RUNTIME ERROR | 0.07 s | details |
| #16 | RUNTIME ERROR | 0.07 s | details |
| #17 | RUNTIME ERROR | 0.06 s | details |
| #18 | ACCEPTED | 0.04 s | details |
| #19 | RUNTIME ERROR | 0.07 s | details |
| #20 | ACCEPTED | 0.04 s | details |
| #21 | RUNTIME ERROR | 0.07 s | details |
Code
n = int(input())
matrice = {i:0 for i in range(n)}
for _ in range(n-1):
a, b = [int(x) for x in input().split()]
matrice[a-1] += 1
matrice[b-1] += 1
less_than_one = []
for i in range(n):
if matrice[i] < 2:
less_than_one.append(i)
print((len(less_than_one) + 1)//2)
while len(less_than_one) > 1:
actual_node = less_than_one.pop()
next_node = less_than_one.pop()
print(actual_node+1, end=' ')
print(next_node + 1)
other_node = n - (less_than_one[0]+1)
print(less_than_one[0]+1, end=' ')
print(other_node + 1)
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 10 1 5 1 7 1 8 1 3 ... |
| correct output |
|---|
| 5 5 2 7 9 8 6 3 10 ... |
| user output |
|---|
| 5 10 9 8 7 6 5 4 3 ... |
Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 10 4 5 3 4 2 3 9 10 ... |
| correct output |
|---|
| 1 10 1 |
| user output |
|---|
| 1 10 1 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 3
Verdict: ACCEPTED
| input |
|---|
| 10 1 8 1 3 3 5 5 7 ... |
| correct output |
|---|
| 3 7 10 8 2 1 9 |
| user output |
|---|
| 3 10 9 8 7 2 9 |
Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 10 1 5 3 7 2 10 3 8 ... |
| correct output |
|---|
| 3 10 8 6 4 5 9 |
| user output |
|---|
| 3 10 9 8 6 5 4 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 5
Verdict: ACCEPTED
| input |
|---|
| 10 4 8 3 4 4 6 2 3 ... |
| correct output |
|---|
| 3 8 7 10 9 1 6 |
| user output |
|---|
| 3 10 9 8 7 6 5 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 100000 1 56967 1 56618 1 42321 1 82550 ... |
| correct output |
|---|
| 50000 56967 16911 56618 39942 42321 99902 82550 2538 ... |
| user output |
|---|
| 50000 100000 99999 99998 99997 99996 99995 99994 99993 ... |
Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 92297 92298 23511 23512 68057 68058 65434 65435 ... |
| correct output |
|---|
| 1 100000 1 |
| user output |
|---|
| 1 100000 1 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 8
Verdict: WRONG ANSWER
| input |
|---|
| 100000 17747 97512 10397 12053 679 6975 4013 14565 ... |
| correct output |
|---|
| 25057 92881 76094 20353 87429 16069 96487 71186 52809 ... |
| user output |
|---|
| 25057 100000 99999 99998 99997 99996 99995 99994 99993 ... |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 100000 72941 72942 11232 11233 73464 73465 30042 30043 ... |
| correct output |
|---|
| 489 16423 85168 20707 94190 36505 54940 96411 44067 ... |
| user output |
|---|
| 489 100000 99989 99956 99906 99902 99879 99823 99674 ... |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 100000 31451 31452 7473 7474 24056 24057 85181 85182 ... |
| correct output |
|---|
| 51 25638 2983 87594 87371 92001 50610 46744 100000 ... |
| user output |
|---|
| 51 100000 99887 98423 96194 94040 93581 92001 90168 ... |
Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| 10 1 2 1 3 3 4 3 5 ... |
| correct output |
|---|
| 2 2 6 4 10 |
| user output |
|---|
| 2 10 6 4 2 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 12
Verdict: RUNTIME ERROR
| input |
|---|
| 7 1 2 2 3 2 4 1 5 ... |
| correct output |
|---|
| 2 4 7 3 6 |
| user output |
|---|
| 2 7 6 4 3 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 13
Verdict: RUNTIME ERROR
| input |
|---|
| 6 1 2 1 3 1 4 4 5 ... |
| correct output |
|---|
| 2 3 6 2 5 |
| user output |
|---|
| 2 6 5 3 2 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 14
Verdict: RUNTIME ERROR
| input |
|---|
| 65538 1 2 1 3 1 4 3 5 ... |
| correct output |
|---|
| 16385 34 36 40 42 35 41 48 50 ... |
| user output |
|---|
| 16385 65538 65537 65536 65535 65532 65531 65530 65529 ... |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 15
Verdict: RUNTIME ERROR
| input |
|---|
| 11 1 2 1 3 2 4 2 5 ... |
| correct output |
|---|
| 2 9 11 8 10 |
| user output |
|---|
| 2 11 10 9 8 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 16
Verdict: RUNTIME ERROR
| input |
|---|
| 7 1 2 1 3 2 4 2 5 ... |
| correct output |
|---|
| 2 5 7 4 6 |
| user output |
|---|
| 2 7 6 5 4 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 17
Verdict: RUNTIME ERROR
| input |
|---|
| 7 1 2 1 3 2 4 2 5 ... |
| correct output |
|---|
| 2 5 7 4 6 |
| user output |
|---|
| 2 7 6 5 4 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 18
Verdict: ACCEPTED
| input |
|---|
| 10 8 4 3 4 4 6 2 3 ... |
| correct output |
|---|
| 3 8 7 10 9 1 6 |
| user output |
|---|
| 3 10 9 8 7 6 5 |
Test 19
Verdict: RUNTIME ERROR
| input |
|---|
| 7 1 2 1 5 2 3 2 6 ... |
| correct output |
|---|
| 2 6 7 3 4 |
| user output |
|---|
| 2 7 6 4 3 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of rangeTest 20
Verdict: ACCEPTED
| input |
|---|
| 8 1 2 1 3 2 4 2 5 ... |
| correct output |
|---|
| 3 4 7 6 8 1 5 |
| user output |
|---|
| 3 8 7 6 5 4 5 |
Test 21
Verdict: RUNTIME ERROR
| input |
|---|
| 10 2 1 3 1 4 2 5 4 ... |
| correct output |
|---|
| 3 9 8 6 10 3 7 |
| user output |
|---|
| 3 10 9 8 7 6 3 |
Error:
Traceback (most recent call last):
File "input/code.py", line 20, in <module>
other_node = n - (less_than_one[0]+1)
IndexError: list index out of range