| Task: | Course Schedule |
| Sender: | aalto26fh_050 |
| Submission time: | 2026-10-01 13:08:53 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.06 s | details |
| #2 | RUNTIME ERROR | 0.06 s | details |
| #3 | RUNTIME ERROR | 0.06 s | details |
| #4 | RUNTIME ERROR | 0.06 s | details |
| #5 | RUNTIME ERROR | 0.06 s | details |
| #6 | RUNTIME ERROR | 0.27 s | details |
| #7 | RUNTIME ERROR | 0.26 s | details |
| #8 | RUNTIME ERROR | 0.27 s | details |
| #9 | RUNTIME ERROR | 0.26 s | details |
| #10 | RUNTIME ERROR | 0.27 s | details |
| #11 | RUNTIME ERROR | 0.21 s | details |
| #12 | RUNTIME ERROR | 0.06 s | details |
| #13 | RUNTIME ERROR | 0.06 s | details |
| #14 | RUNTIME ERROR | 0.23 s | details |
| #15 | RUNTIME ERROR | 0.19 s | details |
| #16 | RUNTIME ERROR | 0.06 s | details |
| #17 | RUNTIME ERROR | 0.21 s | details |
Code
from types import GeneratorType
def bootstrap(f, stack=[]):
def wrapped(*args, **kwargs):
if stack:
return f(*args, **kwargs)
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
else:
stack.pop()
if not stack:
break
to = stack[-1].send(to)
return to
return wrapped
def main():
n, m = map(int, input().split())
adj = [[] for _ in range(n + 1)]
for _ in range(m):
a, b = map(int, input().split())
adj[a].append(b)
status = [0] * (n + 1)
out = []
@bootstrap
def dfs(node: int) -> bool:
if status[node] == 2:
return True
if status[node] == 1:
return False
status[node] = 1
for child in adj[node]:
if not dfs(child):
return False
status[node] = 2
out.append(node)
return True
for i in range(1, n + 1):
if status[i] == 0:
if not dfs(i):
print("IMPOSSIBLE")
return
print(" ".join(str(out[i]) for i in range(n - 1, -1, -1)))
main()
Test details
Test 1
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 5 2 2 4 8 9 6 4 ... |
| correct output |
|---|
| 5 7 10 2 1 8 3 9 6 4 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 2
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 2 7 1 10 9 5 9 7 ... |
| correct output |
|---|
| 1 8 3 6 10 2 9 4 5 7 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 3
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 8 5 2 3 10 1 9 1 ... |
| correct output |
|---|
| 4 6 7 9 10 2 8 3 1 5 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 4
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 5 10 10 3 9 10 6 2 ... |
| correct output |
|---|
| 7 8 6 4 2 1 5 9 10 3 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 5
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 2 9 4 8 9 1 10 6 ... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 6
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 78359 8853 18190 30703 11401 30087 34627 11535 ... |
| correct output |
|---|
| 2 3 8 9 16 18 21 22 27 34 36 4... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in df...Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 32395 2098 67067 31866 31867 67167 78488 33397 ... |
| correct output |
|---|
| 9 11 13 16 22 35 37 38 40 44 5... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 8
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 19035 36947 13730 46121 99449 77790 15626 11731 ... |
| correct output |
|---|
| 1 7 15 17 18 34 38 41 48 49 51... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 9
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 14188 9709 46541 20871 32203 88809 99879 54779 ... |
| correct output |
|---|
| 6 10 11 16 17 19 21 22 23 28 3... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 10
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 41882 61162 28138 18053 74649 74863 69760 74508 ... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in df...Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 199998 1 100000 1 100000 2 100000 2 100000 ... |
| correct output |
|---|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 12
Verdict: RUNTIME ERROR
| input |
|---|
| 2 2 1 2 2 1 |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 13
Verdict: RUNTIME ERROR
| input |
|---|
| 6 6 1 2 2 3 4 3 4 5 ... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 14
Verdict: RUNTIME ERROR
| input |
|---|
| 99999 149997 1 3 3 5 5 7 7 9 ... |
| correct output |
|---|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in df...Test 15
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 149998 2 1 3 2 4 3 5 4 ... |
| correct output |
|---|
| 100000 99999 99998 99997 99996... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 16
Verdict: RUNTIME ERROR
| input |
|---|
| 6 6 1 2 1 3 2 4 3 5 ... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty listTest 17
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 1 1 1 1 2 2 2 2 ... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 59, in <module>
main()
File "/box/input/code.py", line 52, in main
if not dfs(i):
File "/box/input/code.py", line 8, in wrapped
to = f(*args, **kwargs)
File "/box/input/code.py", line 43, in dfs
if not dfs(child):
File "/box/input/code.py", line 14, in wrapped
stack.pop()
IndexError: pop from empty list