結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,404 KB
testcase_01 AC 91 ms
71,900 KB
testcase_02 AC 754 ms
118,692 KB
testcase_03 AC 402 ms
110,188 KB
testcase_04 AC 481 ms
101,712 KB
testcase_05 AC 240 ms
81,780 KB
testcase_06 AC 779 ms
110,264 KB
testcase_07 AC 659 ms
124,772 KB
testcase_08 AC 1,022 ms
125,540 KB
testcase_09 AC 567 ms
124,848 KB
testcase_10 AC 255 ms
86,380 KB
testcase_11 AC 264 ms
86,288 KB
testcase_12 AC 240 ms
86,528 KB
testcase_13 AC 188 ms
83,236 KB
testcase_14 AC 173 ms
80,720 KB
testcase_15 AC 228 ms
86,368 KB
testcase_16 AC 207 ms
84,992 KB
testcase_17 AC 126 ms
77,860 KB
testcase_18 AC 134 ms
77,880 KB
testcase_19 AC 277 ms
86,204 KB
testcase_20 AC 333 ms
116,484 KB
testcase_21 AC 464 ms
100,912 KB
testcase_22 AC 360 ms
124,096 KB
testcase_23 AC 325 ms
125,512 KB
testcase_24 AC 305 ms
118,152 KB
testcase_25 AC 780 ms
110,204 KB
testcase_26 AC 721 ms
107,660 KB
testcase_27 AC 225 ms
82,992 KB
testcase_28 AC 927 ms
120,740 KB
testcase_29 AC 605 ms
99,152 KB
testcase_30 AC 625 ms
103,660 KB
testcase_31 AC 590 ms
132,688 KB
testcase_32 AC 559 ms
119,592 KB
testcase_33 AC 470 ms
111,932 KB
testcase_34 AC 264 ms
98,600 KB
testcase_35 AC 292 ms
93,004 KB
testcase_36 AC 440 ms
95,264 KB
testcase_37 AC 597 ms
107,120 KB
testcase_38 AC 182 ms
80,384 KB
testcase_39 AC 218 ms
85,204 KB
testcase_40 AC 216 ms
85,064 KB
testcase_41 AC 236 ms
88,384 KB
testcase_42 AC 234 ms
88,500 KB
testcase_43 AC 272 ms
109,936 KB
testcase_44 AC 273 ms
109,844 KB
testcase_45 AC 277 ms
109,696 KB
testcase_46 AC 362 ms
111,656 KB
testcase_47 AC 421 ms
110,840 KB
testcase_48 AC 460 ms
113,736 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