結果

問題 No.1473 おでぶなおばけさん
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-11 19:13:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,961 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 43,752 KB
最終ジャッジ日時 2023-09-09 21:20:21
合計ジャッジ時間 36,649 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,552 KB
testcase_01 AC 18 ms
8,532 KB
testcase_02 AC 1,356 ms
40,272 KB
testcase_03 AC 547 ms
36,096 KB
testcase_04 AC 898 ms
26,160 KB
testcase_05 AC 263 ms
14,832 KB
testcase_06 AC 1,401 ms
37,872 KB
testcase_07 AC 1,172 ms
42,984 KB
testcase_08 AC 1,961 ms
43,752 KB
testcase_09 AC 921 ms
42,456 KB
testcase_10 AC 657 ms
29,764 KB
testcase_11 AC 693 ms
28,408 KB
testcase_12 AC 437 ms
30,176 KB
testcase_13 AC 228 ms
20,624 KB
testcase_14 AC 177 ms
17,444 KB
testcase_15 AC 487 ms
25,352 KB
testcase_16 AC 392 ms
28,432 KB
testcase_17 AC 34 ms
9,808 KB
testcase_18 AC 56 ms
10,552 KB
testcase_19 AC 494 ms
27,372 KB
testcase_20 AC 463 ms
32,940 KB
testcase_21 AC 896 ms
34,008 KB
testcase_22 AC 439 ms
33,896 KB
testcase_23 AC 353 ms
30,820 KB
testcase_24 AC 354 ms
29,756 KB
testcase_25 AC 1,719 ms
35,880 KB
testcase_26 AC 1,839 ms
36,988 KB
testcase_27 AC 489 ms
19,940 KB
testcase_28 AC 1,504 ms
41,356 KB
testcase_29 AC 1,027 ms
32,620 KB
testcase_30 AC 1,410 ms
36,440 KB
testcase_31 AC 875 ms
40,680 KB
testcase_32 AC 818 ms
39,004 KB
testcase_33 AC 648 ms
32,752 KB
testcase_34 AC 376 ms
21,236 KB
testcase_35 AC 347 ms
23,080 KB
testcase_36 AC 1,157 ms
29,420 KB
testcase_37 AC 869 ms
31,296 KB
testcase_38 AC 136 ms
13,148 KB
testcase_39 AC 472 ms
28,968 KB
testcase_40 AC 334 ms
28,876 KB
testcase_41 AC 318 ms
25,932 KB
testcase_42 AC 332 ms
25,872 KB
testcase_43 AC 514 ms
35,488 KB
testcase_44 AC 493 ms
35,408 KB
testcase_45 AC 530 ms
35,452 KB
testcase_46 AC 744 ms
33,440 KB
testcase_47 AC 723 ms
38,504 KB
testcase_48 AC 852 ms
36,096 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