結果

問題 No.1473 おでぶなおばけさん
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-11 19:13:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 801 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 113,424 KB
最終ジャッジ日時 2023-09-09 21:20:49
合計ジャッジ時間 17,394 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,652 KB
testcase_01 AC 91 ms
71,432 KB
testcase_02 AC 593 ms
103,432 KB
testcase_03 AC 333 ms
102,812 KB
testcase_04 AC 402 ms
90,540 KB
testcase_05 AC 215 ms
81,108 KB
testcase_06 AC 572 ms
97,764 KB
testcase_07 AC 502 ms
104,916 KB
testcase_08 AC 801 ms
105,500 KB
testcase_09 AC 600 ms
105,448 KB
testcase_10 AC 167 ms
84,464 KB
testcase_11 AC 173 ms
84,388 KB
testcase_12 AC 159 ms
84,916 KB
testcase_13 AC 134 ms
79,988 KB
testcase_14 AC 131 ms
80,156 KB
testcase_15 AC 159 ms
83,740 KB
testcase_16 AC 151 ms
84,148 KB
testcase_17 AC 105 ms
77,532 KB
testcase_18 AC 109 ms
77,384 KB
testcase_19 AC 213 ms
85,000 KB
testcase_20 AC 256 ms
100,912 KB
testcase_21 AC 331 ms
93,988 KB
testcase_22 AC 249 ms
109,028 KB
testcase_23 AC 238 ms
108,544 KB
testcase_24 AC 221 ms
103,984 KB
testcase_25 AC 548 ms
99,056 KB
testcase_26 AC 538 ms
97,344 KB
testcase_27 AC 187 ms
81,776 KB
testcase_28 AC 555 ms
105,192 KB
testcase_29 AC 351 ms
94,192 KB
testcase_30 AC 432 ms
96,632 KB
testcase_31 AC 380 ms
113,424 KB
testcase_32 AC 355 ms
105,160 KB
testcase_33 AC 299 ms
98,100 KB
testcase_34 AC 211 ms
90,448 KB
testcase_35 AC 203 ms
88,232 KB
testcase_36 AC 334 ms
89,384 KB
testcase_37 AC 362 ms
97,020 KB
testcase_38 AC 160 ms
79,660 KB
testcase_39 AC 154 ms
84,196 KB
testcase_40 AC 148 ms
84,184 KB
testcase_41 AC 153 ms
86,840 KB
testcase_42 AC 156 ms
86,796 KB
testcase_43 AC 200 ms
99,592 KB
testcase_44 AC 204 ms
99,696 KB
testcase_45 AC 203 ms
99,380 KB
testcase_46 AC 238 ms
99,080 KB
testcase_47 AC 248 ms
98,592 KB
testcase_48 AC 264 ms
97,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 10**18

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(m):
    dist = [inf] * N
    dist[0] = 0
    q = deque([0])
    while q:
        s = q.popleft()
        for t, d in G[s]:
            if m > d:
                continue
            if dist[t] > dist[s] + 1:
                dist[t] = dist[s] + 1
                q.append(t)
    return dist[N-1]


l = 0
r = 10 ** 10
while r - l > 1:
    m = (r + l) // 2
    L = bfs(m)
    if L >= inf:
        r = m
    else:
        l = m

print(l, bfs(l))
0