結果

問題 No.807 umg tours
ユーザー titiatitia
提出日時 2019-03-22 22:04:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 770 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,608 KB
実行使用メモリ 148,532 KB
最終ジャッジ日時 2023-10-19 09:13:27
合計ジャッジ時間 12,750 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
69,412 KB
testcase_01 AC 70 ms
72,308 KB
testcase_02 AC 79 ms
75,576 KB
testcase_03 AC 71 ms
72,140 KB
testcase_04 AC 65 ms
67,980 KB
testcase_05 AC 67 ms
68,940 KB
testcase_06 AC 81 ms
75,564 KB
testcase_07 AC 77 ms
75,508 KB
testcase_08 AC 43 ms
57,668 KB
testcase_09 AC 48 ms
59,388 KB
testcase_10 AC 55 ms
62,812 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 411 ms
116,272 KB
testcase_21 AC 438 ms
117,768 KB
testcase_22 AC 229 ms
94,548 KB
testcase_23 AC 200 ms
90,416 KB
testcase_24 TLE -
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

def roadsearch(town,dist,maxdist):
    #print(town,dist,maxdist)
    for to,cost in EDGE[town]:
        Flag=0
        maxdist_town=max(maxdist,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