結果

問題 No.1473 おでぶなおばけさん
ユーザー Super SolenoidSuper Solenoid
提出日時 2021-05-16 17:49:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 894 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 102,512 KB
最終ジャッジ日時 2024-04-15 08:32:27
合計ジャッジ時間 17,610 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
54,224 KB
testcase_01 AC 44 ms
54,260 KB
testcase_02 AC 616 ms
102,512 KB
testcase_03 AC 764 ms
97,296 KB
testcase_04 AC 266 ms
86,084 KB
testcase_05 AC 214 ms
80,480 KB
testcase_06 AC 894 ms
99,112 KB
testcase_07 AC 367 ms
93,888 KB
testcase_08 AC 357 ms
93,876 KB
testcase_09 AC 338 ms
94,184 KB
testcase_10 AC 213 ms
83,968 KB
testcase_11 AC 190 ms
84,004 KB
testcase_12 AC 214 ms
84,004 KB
testcase_13 AC 144 ms
80,816 KB
testcase_14 AC 130 ms
78,592 KB
testcase_15 AC 178 ms
83,536 KB
testcase_16 AC 172 ms
82,832 KB
testcase_17 AC 105 ms
77,620 KB
testcase_18 AC 108 ms
77,056 KB
testcase_19 AC 327 ms
85,332 KB
testcase_20 AC 654 ms
96,376 KB
testcase_21 AC 400 ms
89,136 KB
testcase_22 AC 304 ms
89,412 KB
testcase_23 AC 265 ms
90,432 KB
testcase_24 AC 275 ms
89,088 KB
testcase_25 AC 292 ms
88,852 KB
testcase_26 AC 326 ms
91,596 KB
testcase_27 AC 157 ms
80,156 KB
testcase_28 AC 408 ms
93,952 KB
testcase_29 AC 495 ms
89,024 KB
testcase_30 AC 652 ms
92,552 KB
testcase_31 AC 434 ms
93,760 KB
testcase_32 AC 893 ms
100,480 KB
testcase_33 AC 540 ms
92,172 KB
testcase_34 AC 282 ms
83,968 KB
testcase_35 AC 297 ms
85,504 KB
testcase_36 AC 258 ms
86,144 KB
testcase_37 AC 262 ms
89,752 KB
testcase_38 AC 126 ms
77,552 KB
testcase_39 AC 185 ms
83,072 KB
testcase_40 AC 171 ms
82,784 KB
testcase_41 AC 169 ms
87,388 KB
testcase_42 AC 159 ms
87,128 KB
testcase_43 AC 218 ms
92,672 KB
testcase_44 AC 208 ms
92,916 KB
testcase_45 AC 217 ms
92,772 KB
testcase_46 AC 233 ms
88,364 KB
testcase_47 AC 270 ms
89,008 KB
testcase_48 AC 244 ms
88,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
roads = [[] for _ in range(n)]

for i in range(m):
    s, t, d = map(int, input().split())
    s, t = s - 1, t - 1
    roads[s].append((t, d))
    roads[t].append((s, d))

from collections import deque
 
que = deque([(0, 1000000002)])
log = [(-1,-1) for _ in range(n)]

log[0] = (0, 1000000001)

while que:
    cc, cw = que.popleft()
    if log[cc][1] > cw:
        continue
    for nc, nw in roads[cc]:
        d, w = log[nc]
        mw = min(cw, nw)
        if w > mw:
            continue
        elif w == mw:
            if d <= log[cc][0] + 1:
                continue
            #重さが同じなら、距離(道の数)が小さい方へ更新
            log[nc] = (log[cc][0] + 1, mw)
        else:
            #従来の方が軽ければ、重さと距離を更新
            log[nc] = (log[cc][0] + 1, mw)
        que.append((nc, mw))
print(log[n - 1][1], log[n - 1][0])
0