結果

問題 No.1473 おでぶなおばけさん
ユーザー c-yanc-yan
提出日時 2021-04-09 22:49:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 671 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 10,736 KB
実行使用メモリ 49,688 KB
最終ジャッジ日時 2023-09-07 12:26:06
合計ジャッジ時間 9,683 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,548 KB
testcase_01 AC 18 ms
8,548 KB
testcase_02 AC 1,566 ms
47,376 KB
testcase_03 TLE -
testcase_04 AC 467 ms
29,548 KB
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from sys import stdin

readline = stdin.readline

INF = 10 ** 18

n, m = map(int, readline().split())

links = [[] for _ in range(n)]
for _ in range(m):
    s, t, d = map(int, readline().split())
    s, t = s - 1, t - 1
    links[s].append((t, d))
    links[t].append((s, d))

q = deque([(0, INF)])
dp = [(-1, -1) for _ in range(n)]
dp[0] = (INF, -1)
while q:
    cp, mw = q.popleft()
    for np, lw in links[cp]:
        w = dp[np][0]
        nw = min(mw, lw)
        if w >= nw:
            continue
        dp[np] = (nw, cp)
        q.append((np, nw))

c = 0
cp = n - 1
while cp != 0:
    cp = dp[cp][1]
    c += 1
print(dp[n - 1][0], c)
0