結果
| 問題 | No.807 umg tours |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-11 20:41:34 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,849 ms / 4,000 ms |
| コード長 | 595 bytes |
| 記録 | |
| コンパイル時間 | 143 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 156,084 KB |
| 最終ジャッジ日時 | 2026-05-11 20:41:54 |
| 合計ジャッジ時間 | 18,202 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
import heapq
n,m=map(int,input().split())
v=[[] for i in range(n)]
for i in range(m):
a,b,c=map(int,input().split());a-=1;b-=1
v[a].append((b,c));v[b].append((a,c))
dist=[[1<<60]*2 for i in range(n)]
print(0)
hq=[];heapq.heappush(hq,(0,0,0))
while hq:
a,b,c=heapq.heappop(hq)
if dist[b][c]<a:
continue
for i,j in v[b]:
if dist[i][c]>a+j:
dist[i][c]=a+j
heapq.heappush(hq,(a+j,i,c))
if not c and a<dist[i][1]:
dist[i][1]=a
heapq.heappush(hq,(a,i,1))
for i in range(1,n):
print(dist[i][0]+dist[i][1])