結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-14 01:18:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 711 bytes |
| コンパイル時間 | 223 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 169,728 KB |
| 最終ジャッジ日時 | 2024-12-24 03:20:42 |
| 合計ジャッジ時間 | 18,914 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 26 |
ソースコード
import heapq
N,M = map(int,input().split())
lsg = [[] for i in range(2*N)]
for i in range(M):
a,b,c = map(int,input().split())
a -= 1
b -= 1
lsg[a].append((b,c))
lsg[b].append((a,c))
lsg[a].append((b+N,0))
lsg[b].append((a+N,0))
lsg[a+N].append((b+N,c))
lsg[b+N].append((a+N,c))
h = [(0,0)]
INF = float('INF')
cost = [INF]*(2*N)
cost[0] = 0
used = [False]*(2*N)
while h:
c,n = heapq.heappop(h)
if used[n]:
continue
used[n] = True
for nex,cos in lsg[n]:
if used[nex]:
continue
if cost[nex] > c + cos:
cost[nex] = c + cos
heapq.heappush(h, (c+cos,nex))
for i in range(N):
print(cost[i]+cost[i+N])