結果

問題 No.807 umg tours
ユーザー titiatitia
提出日時 2019-03-22 22:13:00
言語 PyPy3
(7.3.15)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 861 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 849,204 KB
最終ジャッジ日時 2023-08-15 12:00:21
合計ジャッジ時間 17,723 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
76,760 KB
testcase_01 AC 103 ms
77,644 KB
testcase_02 AC 114 ms
78,164 KB
testcase_03 AC 111 ms
77,828 KB
testcase_04 AC 104 ms
76,860 KB
testcase_05 AC 109 ms
77,708 KB
testcase_06 AC 112 ms
78,064 KB
testcase_07 AC 116 ms
77,852 KB
testcase_08 AC 98 ms
71,564 KB
testcase_09 AC 96 ms
71,524 KB
testcase_10 AC 94 ms
71,632 KB
testcase_11 AC 1,081 ms
143,916 KB
testcase_12 AC 798 ms
147,472 KB
testcase_13 AC 824 ms
149,884 KB
testcase_14 AC 435 ms
111,468 KB
testcase_15 AC 405 ms
104,208 KB
testcase_16 AC 974 ms
159,860 KB
testcase_17 AC 1,196 ms
183,148 KB
testcase_18 AC 2,196 ms
240,372 KB
testcase_19 AC 1,443 ms
187,004 KB
testcase_20 AC 400 ms
118,724 KB
testcase_21 AC 423 ms
123,284 KB
testcase_22 AC 245 ms
95,976 KB
testcase_23 AC 243 ms
94,100 KB
testcase_24 MLE -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
E=[list(map(int,input().split())) for i in range(M)]

EDGE=[[] for i in range(N+1)]

for x,y,c in E:
    EDGE[x].append([y,c])
    EDGE[y].append([x,c])

MIN=[float("inf")]*(N+1)
MIN2=[float("inf")]*(N+1)

MIN[1]=0
MIN2[1]=0

from collections import deque
QUE=deque([[1,0,0]])

while QUE:
    town,dist,maxdist=QUE.popleft()
    for to,cost in EDGE[town]:
        Flag=0
        if maxdist>cost:
            maxdist_town=maxdist
        else:
            maxdist_town=cost
            

        if MIN[to]>dist+cost:
            MIN[to]=dist+cost
            Flag=1

        if MIN2[to]>dist+cost-maxdist_town:
            MIN2[to]=dist+cost-maxdist_town
            Flag=1

        if Flag:
            QUE.append([to,dist+cost,maxdist_town])

for i in range(1,N+1):
    print(MIN[i]+MIN2[i])
0