結果

問題 No.807 umg tours
ユーザー ttrttr
提出日時 2020-06-21 19:13:23
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 651 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 662,232 KB
最終ジャッジ日時 2023-09-16 18:36:48
合計ジャッジ時間 20,259 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
81,720 KB
testcase_01 AC 114 ms
77,704 KB
testcase_02 AC 122 ms
78,236 KB
testcase_03 AC 115 ms
77,780 KB
testcase_04 AC 112 ms
77,240 KB
testcase_05 AC 115 ms
77,676 KB
testcase_06 AC 122 ms
77,664 KB
testcase_07 AC 115 ms
77,480 KB
testcase_08 AC 93 ms
71,748 KB
testcase_09 AC 103 ms
76,628 KB
testcase_10 AC 105 ms
77,068 KB
testcase_11 AC 1,569 ms
231,088 KB
testcase_12 MLE -
testcase_13 MLE -
testcase_14 AC 721 ms
163,328 KB
testcase_15 AC 602 ms
160,904 KB
testcase_16 AC 1,677 ms
286,712 KB
testcase_17 MLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    E[a].append(c*N+b)
    E[b].append(c*N+a)

from collections import deque
inf = 10**15
d1 = [inf]*N
d2 = [inf]*N
q = deque()
q.append((0, 0, 0))
while q:
    temp = q.popleft()
    u = temp[0]
    len = temp[1]
    dist = temp[2]
    d1[u] = min(d1[u], dist)
    d2[u] = min(d2[u], dist-len)
    for e in E[u]:
        r = e//N
        v = e%N
        if d1[v] <= dist+r and d2[v] <= dist+r-max(len, r):
            continue
        q.append((v, max(len, r), dist+r))

for i in range(N):
    print(d1[i]+d2[i])
0