結果

問題 No.807 umg tours
ユーザー titiatitia
提出日時 2019-03-22 22:06:54
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 875 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 81,488 KB
実行使用メモリ 162,532 KB
最終ジャッジ日時 2023-10-19 09:18:50
合計ジャッジ時間 7,116 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
69,892 KB
testcase_01 AC 67 ms
72,360 KB
testcase_02 AC 78 ms
75,584 KB
testcase_03 AC 65 ms
72,164 KB
testcase_04 AC 61 ms
67,972 KB
testcase_05 AC 63 ms
70,256 KB
testcase_06 AC 80 ms
75,596 KB
testcase_07 AC 79 ms
75,784 KB
testcase_08 AC 44 ms
59,072 KB
testcase_09 AC 46 ms
59,100 KB
testcase_10 AC 53 ms
63,512 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

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

def roadsearch(town,dist,maxdist):
    #print(town,dist,maxdist)
    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:
            roadsearch(to,dist+cost,maxdist_town)

roadsearch(1,0,0)  

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