結果
問題 | No.807 umg tours |
ユーザー |
![]() |
提出日時 | 2021-04-06 08:48:03 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 814 bytes |
コンパイル時間 | 379 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 165,496 KB |
最終ジャッジ日時 | 2025-01-02 16:05:53 |
合計ジャッジ時間 | 16,232 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 21 |
ソースコード
from heapq import *def dijkstra(g,start):n = len(g)INF = 1<<61dist = [INF]*(n) #startからの最短距離dist[start] = dist[start+n//2] = 0q = [(0,start)] #(そこまでの距離、点)while q:dv,v = heappop(q)if dist[v] < dv: continuefor to, cost in g[v]:if dv + cost < dist[to]:dist[to] = dv + costheappush(q, (dist[to], to))return distn,m = map(int,input().split())g = [[] for _ in range(2*n)]for _ in range(m):a,b,c = map(int,input().split())a -= 1b -= 1g[a].append((b,c))g[a].append((b+n,0))g[b].append((a,c))g[b].append((b+n,0))g[a+n].append((b+n,c))g[b+n].append((a+n,c))dist = dijkstra(g,0)for i in range(n):print(dist[i] + dist[i+n])