| Task: | Shortest Routes I |
| Sender: | banghalq |
| Submission time: | 2025-10-03 16:04:09 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.07 s | details |
| #2 | RUNTIME ERROR | 0.07 s | details |
| #3 | RUNTIME ERROR | 0.07 s | details |
| #4 | RUNTIME ERROR | 0.07 s | details |
| #5 | RUNTIME ERROR | 0.07 s | details |
| #6 | RUNTIME ERROR | 0.47 s | details |
| #7 | RUNTIME ERROR | 0.47 s | details |
| #8 | RUNTIME ERROR | 0.47 s | details |
| #9 | RUNTIME ERROR | 0.47 s | details |
| #10 | RUNTIME ERROR | 0.47 s | details |
| #11 | TIME LIMIT EXCEEDED | -- | details |
| #12 | RUNTIME ERROR | 0.33 s | details |
| #13 | ACCEPTED | 0.04 s | details |
| #14 | ACCEPTED | 0.43 s | details |
| #15 | RUNTIME ERROR | 0.34 s | details |
| #16 | TIME LIMIT EXCEEDED | -- | details |
| #17 | TIME LIMIT EXCEEDED | -- | details |
| #18 | TIME LIMIT EXCEEDED | -- | details |
Code
n, m = [int(x) for x in input().split()]
matrice = {i:[] for i in range(n)}
for _ in range(m):
a,b,c = [int(x) for x in input().split()]
matrice[a-1].append((b-1,c))
distance = [float('inf') for _ in range(n)]
distance[0] = 0
not_visited = set(i for i in range(n))
actual_node = 0
searching_min = set([0])
tab_ord_rev_min = []
while len(not_visited) > 1:
for next_node, dist in matrice[actual_node]:
prev_val = distance[next_node]
distance[next_node] = min(distance[next_node], distance[actual_node] + dist)
if next_node in not_visited:
searching_min.add(next_node)
if distance[-1] > distance[next_node]:
tab_ord_rev_min.append(next_node)
else:
i = len(tab_ord_rev_min)-1
while distance[tab_ord_rev_min[i]] < distance[next_node]:
i -= 1
tab_ord_rev_min.insert(i, next_node)
if distance[next_node] < prev_val:
tab_ord_rev_min.sort(key=lambda i: distance[i], reverse=True)
not_visited.remove(actual_node)
searching_min.remove(actual_node)
actual_node = tab_ord_rev_min.pop()
for elt in distance:
print(elt, end=' ')
Test details
Test 1
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 8 5 1 9 10 2 7 9 8 9 8 8 ... |
| correct output |
|---|
| 0 9 11 20 13 14 19 29 27 29 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 3Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 5 6 4 5 1 7 7 4 4 7 8 1 ... |
| correct output |
|---|
| 0 7 9 17 15 17 21 22 25 30 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 3Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 1 4 1 4 2 1 9 10 1 1 2 4 ... |
| correct output |
|---|
| 0 2 11 1 2 7 16 18 12 13 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 1Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 6 3 5 7 5 8 5 1 8 8 9 5 ... |
| correct output |
|---|
| 0 5 9 18 22 10 14 23 27 36 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 4Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 8 9 3 2 3 8 10 5 3 2 5 3 ... |
| correct output |
|---|
| 0 8 16 18 11 17 24 23 16 26 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 24, in <module>
while distance[tab_ord_rev_min[i]] < distance[next_node]:
IndexError: list index out of rangeTest 6
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 18000 18001 426710313 73018 73012 558438094 87726 87671 355171790 53170 53171 869493690 ... |
| correct output |
|---|
| 0 479659405 1165315262 1854343... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 57Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 26504 26450 258578924 49543 49544 28958186 75174 75175 89459846 39175 39228 119699475 ... |
| correct output |
|---|
| 0 655556128 1413395076 1814086... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 4Test 8
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 39477 39413 773046299 69758 69759 558754983 23279 23280 142570619 61416 61479 874921013 ... |
| correct output |
|---|
| 0 269736525 626115013 70199222... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 85Test 9
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 76662 76636 844365635 73339 73342 755006676 89878 89879 396562588 18801 18781 954807004 ... |
| correct output |
|---|
| 0 598585836 1267139909 1803859... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 32Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 200000 11724 11725 818399968 33244 33197 722525474 65530 65531 483965413 62405 62454 199581867 ... |
| correct output |
|---|
| 0 387990617 441010945 92441292... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 82Test 11
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 200000 1 2 1 1 3 1 1 4 1 1 5 1 ... |
| correct output |
|---|
| 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| user output |
|---|
| (empty) |
Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 99999 1 2 1000000000 2 3 1000000000 3 4 1000000000 4 5 1000000000 ... |
| correct output |
|---|
| 0 1000000000 2000000000 300000... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 24, in <module>
while distance[tab_ord_rev_min[i]] < distance[next_node]:
IndexError: list index out of rangeTest 13
Verdict: ACCEPTED
| input |
|---|
| 1 1 1 1 1 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 14
Verdict: ACCEPTED
| input |
|---|
| 99999 149997 1 2 1 2 3 1 3 4 1 4 5 1 ... |
| correct output |
|---|
| 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 ... |
| user output |
|---|
| 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 ... |
Test 15
Verdict: RUNTIME ERROR
| input |
|---|
| 99997 149994 1 3 3 3 5 3 5 7 3 7 9 3 ... |
| correct output |
|---|
| 0 1 2 3 4 5 6 7 8 9 10 11 12 1... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 29, in <module>
not_visited.remove(actual_node)
KeyError: 2Test 16
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 60003 120000 1 2 30010 1 3 30010 1 4 30010 1 5 30010 ... |
| correct output |
|---|
| 0 30010 30010 30010 30010 3001... |
| user output |
|---|
| (empty) |
Test 17
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 60003 120000 1 2 30010 1 3 30010 1 4 30010 1 5 30010 ... |
| correct output |
|---|
| 0 30010 30010 30010 30010 3001... |
| user output |
|---|
| (empty) |
Test 18
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 149997 1 50000 99997 1 49999 99995 1 49998 99993 1 49997 99991 ... |
| correct output |
|---|
| 0 1 3 5 7 9 11 13 15 17 19 21 ... |
| user output |
|---|
| (empty) |
