結果

問題 No.807 umg tours
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-17 11:10:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,302 ms / 4,000 ms
コード長 895 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 163,976 KB
最終ジャッジ日時 2023-11-17 11:10:36
合計ジャッジ時間 16,638 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
63,616 KB
testcase_01 AC 54 ms
65,748 KB
testcase_02 AC 57 ms
65,732 KB
testcase_03 AC 56 ms
65,748 KB
testcase_04 AC 53 ms
63,616 KB
testcase_05 AC 53 ms
63,616 KB
testcase_06 AC 56 ms
65,724 KB
testcase_07 AC 55 ms
65,748 KB
testcase_08 AC 45 ms
55,736 KB
testcase_09 AC 47 ms
57,832 KB
testcase_10 AC 46 ms
57,832 KB
testcase_11 AC 775 ms
136,424 KB
testcase_12 AC 776 ms
124,796 KB
testcase_13 AC 973 ms
143,544 KB
testcase_14 AC 553 ms
104,984 KB
testcase_15 AC 404 ms
98,800 KB
testcase_16 AC 1,030 ms
146,432 KB
testcase_17 AC 1,302 ms
161,004 KB
testcase_18 AC 1,258 ms
160,376 KB
testcase_19 AC 1,200 ms
157,048 KB
testcase_20 AC 646 ms
119,028 KB
testcase_21 AC 632 ms
120,580 KB
testcase_22 AC 325 ms
95,528 KB
testcase_23 AC 267 ms
91,284 KB
testcase_24 AC 582 ms
151,140 KB
testcase_25 AC 1,290 ms
163,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N,M = map(int,input().split())
e = [[] for _ in range(2*N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append((b,c))
    e[a].append((b+N,0))
    e[b].append((a,c))
    e[b].append((a+N,0))
    e[b+N].append((a+N,c))
    e[a+N].append((b+N,c))
INF = (1<<60)
def dijkstra(s,e):
    
    N = len(e)
    dist = [INF]*N
    dist[s]=0
    h = []
    heappush(h,(0,s))
    while h:
        nw,v = heappop(h)
        if dist[v]!=nw:
            continue
        for iv,ic in e[v]:
            nc = ic + nw
            if nc < dist[iv]:
                dist[iv] = nc
                heappush(h,(nc,iv))
    return dist
    
D = dijkstra(0,e)
for i in range(N):
    print(min(D[i]+D[i+N],2*D[i]))
    # print(D[i],D[i+N])
0