結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
Kentarokumura
|
| 提出日時 | 2019-03-22 23:24:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 712 bytes |
| コンパイル時間 | 654 ms |
| コンパイル使用メモリ | 82,252 KB |
| 実行使用メモリ | 269,864 KB |
| 最終ジャッジ日時 | 2024-09-19 06:58:34 |
| 合計ジャッジ時間 | 13,006 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 TLE * 2 -- * 7 |
ソースコード
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])
Kentarokumura