結果

問題 No.807 umg tours
ユーザー KentarokumuraKentarokumura
提出日時 2019-03-22 23:24:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 712 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 81,464 KB
実行使用メモリ 273,556 KB
最終ジャッジ日時 2023-10-19 10:47:55
合計ジャッジ時間 12,919 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
68,072 KB
testcase_01 AC 59 ms
65,968 KB
testcase_02 AC 75 ms
72,484 KB
testcase_03 AC 68 ms
70,408 KB
testcase_04 AC 62 ms
66,024 KB
testcase_05 AC 57 ms
65,896 KB
testcase_06 AC 58 ms
63,712 KB
testcase_07 AC 69 ms
70,392 KB
testcase_08 AC 44 ms
55,480 KB
testcase_09 AC 49 ms
61,408 KB
testcase_10 AC 49 ms
61,408 KB
testcase_11 AC 2,617 ms
177,052 KB
testcase_12 AC 2,570 ms
174,996 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop,heappush
from collections import deque
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
table=[[] for i in range(2*N)]
for i in range(M):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    table[a].append((b,c))
    table[b].append((a,c))
    table[a].append((N+b,0))
    table[b].append((N+a,0))
    table[N+a].append((N+b,c))
    table[N+b].append((N+a,c))
H=[]
cost=[10**18]*(2*N)
cost[0]=0
H.append((0,0))
while H:
    pt,cos=heappop(H)
    if cost[pt]<cos:
        continue
    for y,c in table[pt]:
        if cost[y]>cost[pt]+c:
            cost[y]=cost[pt]+c
            heappush(H,(y,cost[y]))
print(0)
for i in range(1,N):
    print(cost[i]+cost[N+i])


0