結果

問題 No.1473 おでぶなおばけさん
ユーザー aqua_tenhouaqua_tenhou
提出日時 2022-01-04 19:08:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,409 ms / 2,000 ms
コード長 795 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 86,680 KB
実行使用メモリ 130,448 KB
最終ジャッジ日時 2023-08-04 17:40:42
合計ジャッジ時間 31,230 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
71,544 KB
testcase_01 AC 84 ms
71,244 KB
testcase_02 AC 889 ms
122,484 KB
testcase_03 AC 542 ms
121,988 KB
testcase_04 AC 748 ms
102,520 KB
testcase_05 AC 275 ms
85,636 KB
testcase_06 AC 1,120 ms
117,984 KB
testcase_07 AC 851 ms
124,188 KB
testcase_08 AC 1,393 ms
124,940 KB
testcase_09 AC 790 ms
127,748 KB
testcase_10 AC 316 ms
101,640 KB
testcase_11 AC 357 ms
101,404 KB
testcase_12 AC 317 ms
102,028 KB
testcase_13 AC 232 ms
96,276 KB
testcase_14 AC 201 ms
82,784 KB
testcase_15 AC 306 ms
92,896 KB
testcase_16 AC 256 ms
103,192 KB
testcase_17 AC 135 ms
80,248 KB
testcase_18 AC 147 ms
79,320 KB
testcase_19 AC 333 ms
101,328 KB
testcase_20 AC 450 ms
115,132 KB
testcase_21 AC 579 ms
113,904 KB
testcase_22 AC 393 ms
126,568 KB
testcase_23 AC 355 ms
122,480 KB
testcase_24 AC 351 ms
118,660 KB
testcase_25 AC 1,409 ms
120,836 KB
testcase_26 AC 1,305 ms
120,244 KB
testcase_27 AC 364 ms
92,716 KB
testcase_28 AC 1,073 ms
127,084 KB
testcase_29 AC 651 ms
114,068 KB
testcase_30 AC 877 ms
117,876 KB
testcase_31 AC 733 ms
130,448 KB
testcase_32 AC 613 ms
122,528 KB
testcase_33 AC 508 ms
116,028 KB
testcase_34 AC 353 ms
98,032 KB
testcase_35 AC 293 ms
100,764 KB
testcase_36 AC 408 ms
107,832 KB
testcase_37 AC 840 ms
111,908 KB
testcase_38 AC 181 ms
83,912 KB
testcase_39 AC 273 ms
101,988 KB
testcase_40 AC 273 ms
101,964 KB
testcase_41 AC 281 ms
100,864 KB
testcase_42 AC 250 ms
100,848 KB
testcase_43 AC 303 ms
119,956 KB
testcase_44 AC 309 ms
119,932 KB
testcase_45 AC 317 ms
120,072 KB
testcase_46 AC 491 ms
113,284 KB
testcase_47 AC 554 ms
116,548 KB
testcase_48 AC 403 ms
116,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def is_ok(arg):
    w = BWS(arg)
    return w != 10**18

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

def BWS(w):
    q = deque([])
    reach = [10**18]*(n+1)

    q.append(1)
    reach[1] = 0
    while q:
        x = q.popleft()
        for y,z in V[x]:
            if reach[y] > reach[x] + 1 and w <= z:
                q.append(y)
                reach[y] = reach[x] + 1
    return reach[-1]

n,m = map(int,input().split())
z = [list(map(int,input().split())) for i in range(m)]
V = [[] for i in range(n+1)]
for s,t,d in z:
    V[s].append([t,d])
    V[t].append([s,d])

ans = meguru_bisect(10**9 + 1, 0)
print(ans, BWS(ans))
0