結果

問題 No.807 umg tours
ユーザー tobusakanatobusakana
提出日時 2022-12-01 21:13:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,025 ms / 4,000 ms
コード長 907 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 235,704 KB
最終ジャッジ日時 2024-04-17 09:05:25
合計ジャッジ時間 20,938 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
61,568 KB
testcase_01 AC 53 ms
61,440 KB
testcase_02 AC 61 ms
63,488 KB
testcase_03 AC 61 ms
62,720 KB
testcase_04 AC 58 ms
61,568 KB
testcase_05 AC 57 ms
61,696 KB
testcase_06 AC 63 ms
63,744 KB
testcase_07 AC 62 ms
63,872 KB
testcase_08 AC 45 ms
52,352 KB
testcase_09 AC 45 ms
52,608 KB
testcase_10 AC 45 ms
53,120 KB
testcase_11 AC 1,200 ms
195,932 KB
testcase_12 AC 1,538 ms
165,180 KB
testcase_13 AC 1,449 ms
201,440 KB
testcase_14 AC 704 ms
129,252 KB
testcase_15 AC 544 ms
119,168 KB
testcase_16 AC 1,640 ms
211,316 KB
testcase_17 AC 2,025 ms
232,596 KB
testcase_18 AC 1,906 ms
231,748 KB
testcase_19 AC 1,758 ms
228,096 KB
testcase_20 AC 898 ms
152,576 KB
testcase_21 AC 938 ms
156,008 KB
testcase_22 AC 445 ms
110,504 KB
testcase_23 AC 380 ms
103,008 KB
testcase_24 AC 864 ms
206,096 KB
testcase_25 AC 1,875 ms
235,704 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