結果

問題 No.1473 おでぶなおばけさん
ユーザー c-yanc-yan
提出日時 2021-04-09 22:58:04
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 769 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 102,476 KB
最終ジャッジ日時 2023-09-07 12:37:46
合計ジャッジ時間 16,411 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,836 KB
testcase_01 AC 90 ms
71,636 KB
testcase_02 AC 487 ms
96,108 KB
testcase_03 AC 662 ms
100,204 KB
testcase_04 AC 248 ms
87,248 KB
testcase_05 AC 190 ms
81,216 KB
testcase_06 AC 769 ms
102,476 KB
testcase_07 AC 317 ms
94,528 KB
testcase_08 AC 321 ms
94,544 KB
testcase_09 AC 284 ms
94,184 KB
testcase_10 AC 182 ms
85,684 KB
testcase_11 AC 181 ms
85,820 KB
testcase_12 AC 188 ms
86,104 KB
testcase_13 AC 147 ms
82,196 KB
testcase_14 AC 131 ms
79,576 KB
testcase_15 AC 156 ms
81,920 KB
testcase_16 AC 162 ms
84,868 KB
testcase_17 AC 114 ms
78,004 KB
testcase_18 AC 117 ms
77,812 KB
testcase_19 AC 286 ms
86,048 KB
testcase_20 AC 507 ms
95,128 KB
testcase_21 AC 312 ms
90,376 KB
testcase_22 AC 249 ms
92,136 KB
testcase_23 AC 220 ms
89,656 KB
testcase_24 AC 228 ms
88,252 KB
testcase_25 AC 236 ms
90,824 KB
testcase_26 AC 258 ms
90,588 KB
testcase_27 AC 160 ms
80,788 KB
testcase_28 AC 355 ms
97,240 KB
testcase_29 AC 396 ms
91,740 KB
testcase_30 AC 500 ms
96,108 KB
testcase_31 AC 366 ms
96,628 KB
testcase_32 AC 716 ms
99,508 KB
testcase_33 AC 480 ms
95,352 KB
testcase_34 AC 252 ms
85,604 KB
testcase_35 AC 245 ms
84,952 KB
testcase_36 AC 205 ms
85,032 KB
testcase_37 AC 218 ms
88,584 KB
testcase_38 AC 124 ms
78,024 KB
testcase_39 AC 165 ms
85,028 KB
testcase_40 AC 157 ms
84,924 KB
testcase_41 AC 146 ms
87,908 KB
testcase_42 AC 145 ms
87,852 KB
testcase_43 AC 188 ms
92,040 KB
testcase_44 AC 184 ms
92,332 KB
testcase_45 AC 189 ms
92,200 KB
testcase_46 AC 199 ms
87,928 KB
testcase_47 AC 222 ms
91,212 KB
testcase_48 AC 219 ms
91,468 KB
権限があれば一括ダウンロードができます

ソースコード

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, 0)
while q:
    cp, mw = q.popleft()
    if dp[cp][0] > mw:
        continue
    for np, lw in links[cp]:
        w, s = dp[np]
        nw = min(mw, lw)
        if w >= nw:
            continue
        if w == nw:
            dp[np] = (nw, min(s, dp[cp][1] + 1))
        else:
            dp[np] = (nw, dp[cp][1] + 1)
        q.append((np, nw))
print(dp[n - 1][0], dp[n - 1][1])
0