結果

問題 No.807 umg tours
ユーザー titiatitia
提出日時 2019-03-22 22:18:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 978 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 118,404 KB
最終ジャッジ日時 2023-08-15 12:02:11
合計ジャッジ時間 31,131 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,772 KB
testcase_01 AC 21 ms
8,740 KB
testcase_02 AC 24 ms
8,880 KB
testcase_03 AC 22 ms
8,804 KB
testcase_04 AC 20 ms
8,784 KB
testcase_05 AC 20 ms
8,708 KB
testcase_06 AC 22 ms
8,892 KB
testcase_07 AC 22 ms
8,692 KB
testcase_08 AC 19 ms
8,696 KB
testcase_09 AC 20 ms
8,544 KB
testcase_10 AC 20 ms
8,736 KB
testcase_11 AC 3,417 ms
89,572 KB
testcase_12 AC 1,721 ms
72,208 KB
testcase_13 AC 2,458 ms
94,168 KB
testcase_14 AC 866 ms
46,664 KB
testcase_15 AC 733 ms
39,504 KB
testcase_16 AC 2,894 ms
103,072 KB
testcase_17 AC 2,945 ms
112,000 KB
testcase_18 TLE -
testcase_19 AC 3,395 ms
115,952 KB
testcase_20 AC 949 ms
63,712 KB
testcase_21 AC 966 ms
65,664 KB
testcase_22 AC 357 ms
33,380 KB
testcase_23 AC 285 ms
28,236 KB
testcase_24 AC 1,198 ms
92,432 KB
testcase_25 AC 2,525 ms
115,120 KB
権限があれば一括ダウンロードができます

ソースコード

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=[10**15]*(N+1)
MIN2=[10**15]*(N+1)

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

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

while QUE:
    town,dist,maxdist=QUE.popleft()
    if MIN[town]<dist and MIN2[town]<dist-maxdist:
        continue
    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