10015 | 2024-03-24 09:55:11 | 111 | Autópálya infláció | pypy3 | Runtime error 0/100 | 165ms | 102308 KiB |
import math
N, M = map(int, input().split())
g = [[] for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
g[a].append((b, c))
g[b].append((a, c))
dp = [[math.inf, math.inf] for _ in range(N)]
dp[0][0] = 0
for i in range(N - 1):
v = []
for j in range(N):
if i > 0 and dp[j][i % 2] >= dp[j][(i % 2) ^ 1]:
dp[j][i % 2] = dp[j][(i % 2) ^ 1]
continue
v.append(j)
for j in v:
for k, w in g[j]:
dp[k][(i % 2) ^ 1] = min(dp[k][(i % 2) ^ 1], dp[j][i % 2] + w * ipow(2, i))
for i in range(1, N):
print(int(min(dp[i]) % 1000000007))
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Runtime error | 90ms | 89308 KiB | ||||
2 | Runtime error | 140ms | 95668 KiB | ||||
subtask2 | 0/8 | ||||||
3 | Runtime error | 141ms | 96244 KiB | ||||
4 | Runtime error | 134ms | 96212 KiB | ||||
5 | Runtime error | 141ms | 96536 KiB | ||||
6 | Runtime error | 141ms | 96936 KiB | ||||
7 | Runtime error | 133ms | 97288 KiB | ||||
subtask3 | 0/15 | ||||||
8 | Runtime error | 87ms | 91372 KiB | ||||
9 | Runtime error | 82ms | 91480 KiB | ||||
10 | Runtime error | 89ms | 91724 KiB | ||||
11 | Runtime error | 82ms | 91808 KiB | ||||
12 | Runtime error | 92ms | 92032 KiB | ||||
13 | Runtime error | 82ms | 92436 KiB | ||||
14 | Runtime error | 89ms | 92312 KiB | ||||
15 | Runtime error | 89ms | 92224 KiB | ||||
16 | Runtime error | 89ms | 92736 KiB | ||||
17 | Runtime error | 90ms | 92932 KiB | ||||
18 | Runtime error | 90ms | 92944 KiB | ||||
subtask4 | 0/34 | ||||||
19 | Runtime error | 165ms | 99056 KiB | ||||
20 | Runtime error | 138ms | 99100 KiB | ||||
21 | Runtime error | 164ms | 99652 KiB | ||||
22 | Runtime error | 148ms | 99168 KiB | ||||
23 | Runtime error | 140ms | 99016 KiB | ||||
24 | Runtime error | 146ms | 99164 KiB | ||||
25 | Runtime error | 140ms | 99588 KiB | ||||
26 | Runtime error | 146ms | 99708 KiB | ||||
27 | Runtime error | 164ms | 101316 KiB | ||||
28 | Runtime error | 143ms | 98796 KiB | ||||
29 | Runtime error | 136ms | 99376 KiB | ||||
30 | Runtime error | 130ms | 99308 KiB | ||||
31 | Runtime error | 130ms | 99352 KiB | ||||
32 | Runtime error | 136ms | 100208 KiB | ||||
33 | Runtime error | 164ms | 100392 KiB | ||||
subtask5 | 0/21 | ||||||
34 | Runtime error | 114ms | 94904 KiB | ||||
35 | Runtime error | 125ms | 97624 KiB | ||||
36 | Runtime error | 130ms | 97424 KiB | ||||
37 | Runtime error | 130ms | 97592 KiB | ||||
38 | Runtime error | 125ms | 97288 KiB | ||||
39 | Runtime error | 130ms | 97524 KiB | ||||
40 | Runtime error | 123ms | 97252 KiB | ||||
41 | Runtime error | 119ms | 97204 KiB | ||||
42 | Runtime error | 101ms | 93836 KiB | ||||
43 | Runtime error | 94ms | 93600 KiB | ||||
44 | Runtime error | 100ms | 93552 KiB | ||||
45 | Runtime error | 93ms | 93644 KiB | ||||
46 | Runtime error | 90ms | 93536 KiB | ||||
47 | Runtime error | 90ms | 93620 KiB | ||||
48 | Runtime error | 112ms | 94604 KiB | ||||
49 | Runtime error | 105ms | 94412 KiB | ||||
subtask6 | 0/22 | ||||||
50 | Runtime error | 136ms | 100024 KiB | ||||
51 | Runtime error | 146ms | 100164 KiB | ||||
52 | Runtime error | 164ms | 99692 KiB | ||||
53 | Runtime error | 148ms | 100560 KiB | ||||
54 | Runtime error | 149ms | 100176 KiB | ||||
55 | Runtime error | 140ms | 99948 KiB | ||||
56 | Runtime error | 160ms | 102308 KiB | ||||
57 | Runtime error | 160ms | 102072 KiB | ||||
58 | Runtime error | 103ms | 94392 KiB | ||||
59 | Runtime error | 130ms | 99872 KiB | ||||
60 | Runtime error | 143ms | 99640 KiB | ||||
61 | Runtime error | 136ms | 99556 KiB | ||||
62 | Runtime error | 143ms | 100112 KiB | ||||
63 | Runtime error | 136ms | 100084 KiB | ||||
64 | Runtime error | 149ms | 99660 KiB | ||||
65 | Runtime error | 149ms | 100360 KiB | ||||
66 | Runtime error | 142ms | 99888 KiB |