結果

問題 No.1473 おでぶなおばけさん
ユーザー irumo8202irumo8202
提出日時 2022-01-30 14:17:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 726 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 133,040 KB
最終ジャッジ日時 2023-09-02 01:36:43
合計ジャッジ時間 18,018 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
71,784 KB
testcase_01 AC 84 ms
71,712 KB
testcase_02 AC 538 ms
118,988 KB
testcase_03 AC 346 ms
110,224 KB
testcase_04 AC 400 ms
101,948 KB
testcase_05 AC 226 ms
81,772 KB
testcase_06 AC 527 ms
110,416 KB
testcase_07 AC 535 ms
124,556 KB
testcase_08 AC 726 ms
125,536 KB
testcase_09 AC 448 ms
124,788 KB
testcase_10 AC 220 ms
86,392 KB
testcase_11 AC 238 ms
86,436 KB
testcase_12 AC 208 ms
86,204 KB
testcase_13 AC 164 ms
83,292 KB
testcase_14 AC 157 ms
80,740 KB
testcase_15 AC 211 ms
86,152 KB
testcase_16 AC 191 ms
84,844 KB
testcase_17 AC 118 ms
77,976 KB
testcase_18 AC 126 ms
77,764 KB
testcase_19 AC 247 ms
86,356 KB
testcase_20 AC 295 ms
116,676 KB
testcase_21 AC 368 ms
100,676 KB
testcase_22 AC 298 ms
124,392 KB
testcase_23 AC 267 ms
125,452 KB
testcase_24 AC 258 ms
117,908 KB
testcase_25 AC 624 ms
110,244 KB
testcase_26 AC 507 ms
107,640 KB
testcase_27 AC 203 ms
83,176 KB
testcase_28 AC 611 ms
120,972 KB
testcase_29 AC 406 ms
99,076 KB
testcase_30 AC 428 ms
103,632 KB
testcase_31 AC 405 ms
133,040 KB
testcase_32 AC 391 ms
119,768 KB
testcase_33 AC 343 ms
111,828 KB
testcase_34 AC 222 ms
98,456 KB
testcase_35 AC 250 ms
93,408 KB
testcase_36 AC 329 ms
95,332 KB
testcase_37 AC 425 ms
107,200 KB
testcase_38 AC 171 ms
80,540 KB
testcase_39 AC 195 ms
84,960 KB
testcase_40 AC 188 ms
84,852 KB
testcase_41 AC 216 ms
88,412 KB
testcase_42 AC 224 ms
88,096 KB
testcase_43 AC 256 ms
109,580 KB
testcase_44 AC 251 ms
110,012 KB
testcase_45 AC 252 ms
109,704 KB
testcase_46 AC 276 ms
111,824 KB
testcase_47 AC 307 ms
111,040 KB
testcase_48 AC 322 ms
113,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, M = map(int, input().split())

G = [[] for _ in range(N)]

for _ in range(M):
    s, t, d = map(int, input().split())
    s -= 1
    t -= 1
    G[s].append((t, d))
    G[t].append((s, d))


def bfs(lim):
    que = deque([0])
    dist = [-1] * N
    dist[0] = 0
    while que:
        node = que.popleft()
        nears = G[node]

        for near, d in nears:
            if dist[near] != -1:
                continue
            if d >= lim:
                dist[near] = dist[node] + 1
                que.append(near)
    return dist[-1]


left = 0
right = 10 ** 18

while right - left > 1:
    mid = (right + left) // 2
    if bfs(mid) == -1:
        right = mid
    else:
        left = mid

print(left, bfs(left))
0