10016 | 2024-03-24 09:57:01 | 111 | Autópálya infláció | pypy3 | Accepted 100/100 | 823ms | 104960 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 * pow(2, i))
for i in range(1, N):
print(min(dp[i]) % 1000000007)
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 48ms | 76764 KiB | ||||
2 | Accepted | 787ms | 98700 KiB | ||||
subtask2 | 8/8 | ||||||
3 | Accepted | 456ms | 96492 KiB | ||||
4 | Accepted | 504ms | 97920 KiB | ||||
5 | Accepted | 732ms | 98176 KiB | ||||
6 | Accepted | 561ms | 97108 KiB | ||||
7 | Accepted | 702ms | 97896 KiB | ||||
subtask3 | 15/15 | ||||||
8 | Accepted | 48ms | 78112 KiB | ||||
9 | Accepted | 43ms | 78148 KiB | ||||
10 | Accepted | 48ms | 78248 KiB | ||||
11 | Accepted | 43ms | 78400 KiB | ||||
12 | Accepted | 50ms | 78404 KiB | ||||
13 | Accepted | 48ms | 78080 KiB | ||||
14 | Accepted | 50ms | 78088 KiB | ||||
15 | Accepted | 43ms | 78548 KiB | ||||
16 | Accepted | 48ms | 78484 KiB | ||||
17 | Accepted | 45ms | 78516 KiB | ||||
18 | Accepted | 41ms | 79252 KiB | ||||
subtask4 | 34/34 | ||||||
19 | Accepted | 469ms | 98524 KiB | ||||
20 | Accepted | 656ms | 100256 KiB | ||||
21 | Accepted | 644ms | 99136 KiB | ||||
22 | Accepted | 375ms | 98520 KiB | ||||
23 | Accepted | 465ms | 98300 KiB | ||||
24 | Accepted | 745ms | 99696 KiB | ||||
25 | Accepted | 476ms | 98216 KiB | ||||
26 | Accepted | 500ms | 99984 KiB | ||||
27 | Accepted | 632ms | 103040 KiB | ||||
28 | Accepted | 607ms | 100872 KiB | ||||
29 | Accepted | 615ms | 100388 KiB | ||||
30 | Accepted | 546ms | 100376 KiB | ||||
31 | Accepted | 620ms | 101372 KiB | ||||
32 | Accepted | 601ms | 99880 KiB | ||||
33 | Accepted | 620ms | 100812 KiB | ||||
subtask5 | 21/21 | ||||||
34 | Accepted | 128ms | 92756 KiB | ||||
35 | Accepted | 141ms | 94996 KiB | ||||
36 | Accepted | 144ms | 94444 KiB | ||||
37 | Accepted | 144ms | 95088 KiB | ||||
38 | Accepted | 129ms | 94584 KiB | ||||
39 | Accepted | 141ms | 95100 KiB | ||||
40 | Accepted | 178ms | 97108 KiB | ||||
41 | Accepted | 194ms | 97456 KiB | ||||
42 | Accepted | 111ms | 93320 KiB | ||||
43 | Accepted | 116ms | 92848 KiB | ||||
44 | Accepted | 115ms | 92508 KiB | ||||
45 | Accepted | 109ms | 92700 KiB | ||||
46 | Accepted | 119ms | 93104 KiB | ||||
47 | Accepted | 115ms | 92984 KiB | ||||
48 | Accepted | 133ms | 93560 KiB | ||||
49 | Accepted | 126ms | 93044 KiB | ||||
subtask6 | 22/22 | ||||||
50 | Accepted | 823ms | 100204 KiB | ||||
51 | Accepted | 783ms | 102228 KiB | ||||
52 | Accepted | 517ms | 101448 KiB | ||||
53 | Accepted | 504ms | 101004 KiB | ||||
54 | Accepted | 570ms | 101756 KiB | ||||
55 | Accepted | 630ms | 100976 KiB | ||||
56 | Accepted | 686ms | 104960 KiB | ||||
57 | Accepted | 651ms | 104728 KiB | ||||
58 | Accepted | 171ms | 93948 KiB | ||||
59 | Accepted | 624ms | 100748 KiB | ||||
60 | Accepted | 657ms | 100652 KiB | ||||
61 | Accepted | 598ms | 100604 KiB | ||||
62 | Accepted | 660ms | 100288 KiB | ||||
63 | Accepted | 663ms | 100840 KiB | ||||
64 | Accepted | 554ms | 100868 KiB | ||||
65 | Accepted | 629ms | 102076 KiB | ||||
66 | Accepted | 587ms | 99764 KiB |