結果

問題 No.807 umg tours
ユーザー tobusakanatobusakana
提出日時 2022-12-01 21:13:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,777 ms / 4,000 ms
コード長 907 bytes
コンパイル時間 834 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 238,572 KB
最終ジャッジ日時 2023-07-30 07:43:19
合計ジャッジ時間 24,683 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
76,112 KB
testcase_01 AC 83 ms
76,108 KB
testcase_02 AC 90 ms
76,148 KB
testcase_03 AC 87 ms
76,000 KB
testcase_04 AC 83 ms
76,004 KB
testcase_05 AC 82 ms
76,248 KB
testcase_06 AC 88 ms
76,288 KB
testcase_07 AC 88 ms
76,584 KB
testcase_08 AC 79 ms
71,500 KB
testcase_09 AC 74 ms
71,468 KB
testcase_10 AC 79 ms
71,572 KB
testcase_11 AC 1,190 ms
197,688 KB
testcase_12 AC 1,116 ms
167,532 KB
testcase_13 AC 1,407 ms
203,544 KB
testcase_14 AC 720 ms
131,532 KB
testcase_15 AC 550 ms
121,928 KB
testcase_16 AC 1,476 ms
213,516 KB
testcase_17 AC 1,777 ms
234,904 KB
testcase_18 AC 1,691 ms
233,560 KB
testcase_19 AC 1,629 ms
229,912 KB
testcase_20 AC 835 ms
154,704 KB
testcase_21 AC 868 ms
158,712 KB
testcase_22 AC 434 ms
111,716 KB
testcase_23 AC 374 ms
105,128 KB
testcase_24 AC 804 ms
206,860 KB
testcase_25 AC 1,736 ms
238,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
G = [[] for i in range(2 * N)]
for _ in range(M):
    a,b,c = map(int,readline().split())
    a -= 1
    b -= 1
    G[a].append([b, c])
    G[b].append([a, c])
    G[a].append([b + N, 0])
    G[b].append([a + N, 0])
    G[a + N].append([b + N, c])
    G[b + N].append([a + N, c])

INF = 1 << 60
dist = [0] * (2 * N)
best = [INF] * (2 * N)
visited = [False] * (2 * N)
import heapq as hq
q = []
hq.heappush(q, (0, 0))
while q:
    d,v = hq.heappop(q)
    if visited[v]:
        continue
    visited[v] = True
    dist[v] = d
    for child, cost in G[v]:
        if visited[child]:
            continue
        if best[child] <= d + cost:
            continue
        best[child] = d + cost
        hq.heappush(q, (d + cost, child))
        
print(0)
for i in range(1, N):
    print(dist[i] + dist[i + N])
    
    
            





0