結果
問題 | No.807 umg tours |
ユーザー |
![]() |
提出日時 | 2019-03-22 23:29:16 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 681 bytes |
コンパイル時間 | 139 ms |
コンパイル使用メモリ | 82,288 KB |
実行使用メモリ | 145,264 KB |
最終ジャッジ日時 | 2024-09-19 07:01:01 |
合計ジャッジ時間 | 6,893 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 26 |
ソースコード
from heapq import heappop,heappush 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**16]*(2*N) cost[0]=0 H.append((0,0)) while H: cos,y=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,(cost[y],y)) print(0) for i in range(1,N): print(cost[i]+cost[N+i])