結果

問題 No.1473 おでぶなおばけさん
ユーザー aqua_tenhouaqua_tenhou
提出日時 2021-04-09 22:08:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,734 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 146,912 KB
最終ジャッジ日時 2023-09-07 11:32:02
合計ジャッジ時間 31,783 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,616 KB
testcase_01 AC 89 ms
71,524 KB
testcase_02 AC 1,163 ms
127,688 KB
testcase_03 AC 743 ms
131,900 KB
testcase_04 AC 921 ms
105,608 KB
testcase_05 AC 295 ms
85,720 KB
testcase_06 AC 1,180 ms
122,592 KB
testcase_07 AC 963 ms
131,372 KB
testcase_08 AC 1,513 ms
129,344 KB
testcase_09 AC 922 ms
137,868 KB
testcase_10 AC 341 ms
101,684 KB
testcase_11 AC 385 ms
101,304 KB
testcase_12 AC 342 ms
102,028 KB
testcase_13 AC 254 ms
95,848 KB
testcase_14 AC 222 ms
82,872 KB
testcase_15 AC 364 ms
93,160 KB
testcase_16 AC 304 ms
102,912 KB
testcase_17 AC 140 ms
80,096 KB
testcase_18 AC 151 ms
79,284 KB
testcase_19 AC 421 ms
101,196 KB
testcase_20 AC 562 ms
124,588 KB
testcase_21 AC 738 ms
118,532 KB
testcase_22 AC 452 ms
142,932 KB
testcase_23 AC 426 ms
139,052 KB
testcase_24 AC 406 ms
132,500 KB
testcase_25 AC 1,649 ms
122,484 KB
testcase_26 AC 1,734 ms
122,296 KB
testcase_27 AC 397 ms
92,484 KB
testcase_28 AC 1,169 ms
133,836 KB
testcase_29 AC 771 ms
119,520 KB
testcase_30 AC 1,119 ms
123,116 KB
testcase_31 AC 867 ms
146,912 KB
testcase_32 AC 798 ms
132,144 KB
testcase_33 AC 636 ms
126,572 KB
testcase_34 AC 428 ms
103,056 KB
testcase_35 AC 365 ms
106,448 KB
testcase_36 AC 572 ms
111,744 KB
testcase_37 AC 987 ms
115,900 KB
testcase_38 AC 206 ms
84,056 KB
testcase_39 AC 300 ms
101,912 KB
testcase_40 AC 301 ms
101,836 KB
testcase_41 AC 296 ms
100,780 KB
testcase_42 AC 281 ms
100,760 KB
testcase_43 AC 356 ms
126,352 KB
testcase_44 AC 366 ms
126,312 KB
testcase_45 AC 356 ms
126,348 KB
testcase_46 AC 578 ms
121,380 KB
testcase_47 AC 686 ms
123,972 KB
testcase_48 AC 504 ms
126,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def is_ok(arg):
    w = BWS(arg)
    return w != float("Inf")


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 = [float("Inf")]*(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