結果

問題 No.1473 おでぶなおばけさん
ユーザー aqua_tenhouaqua_tenhou
提出日時 2022-01-04 19:08:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,565 ms / 2,000 ms
コード長 795 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 129,792 KB
最終ジャッジ日時 2024-04-22 15:45:15
合計ジャッジ時間 30,643 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
53,504 KB
testcase_01 AC 50 ms
53,760 KB
testcase_02 AC 1,054 ms
124,276 KB
testcase_03 AC 647 ms
119,264 KB
testcase_04 AC 917 ms
101,408 KB
testcase_05 AC 276 ms
84,480 KB
testcase_06 AC 1,170 ms
118,072 KB
testcase_07 AC 931 ms
123,944 KB
testcase_08 AC 1,502 ms
123,428 KB
testcase_09 AC 847 ms
125,612 KB
testcase_10 AC 325 ms
95,616 KB
testcase_11 AC 380 ms
95,232 KB
testcase_12 AC 321 ms
95,360 KB
testcase_13 AC 214 ms
90,368 KB
testcase_14 AC 183 ms
89,344 KB
testcase_15 AC 296 ms
100,864 KB
testcase_16 AC 274 ms
96,768 KB
testcase_17 AC 104 ms
77,568 KB
testcase_18 AC 119 ms
77,568 KB
testcase_19 AC 347 ms
99,584 KB
testcase_20 AC 504 ms
116,352 KB
testcase_21 AC 667 ms
112,512 KB
testcase_22 AC 385 ms
126,848 KB
testcase_23 AC 360 ms
115,216 KB
testcase_24 AC 350 ms
116,992 KB
testcase_25 AC 1,559 ms
117,544 KB
testcase_26 AC 1,565 ms
119,472 KB
testcase_27 AC 378 ms
91,136 KB
testcase_28 AC 1,060 ms
124,964 KB
testcase_29 AC 704 ms
112,256 KB
testcase_30 AC 999 ms
116,096 KB
testcase_31 AC 848 ms
129,792 KB
testcase_32 AC 730 ms
120,576 KB
testcase_33 AC 591 ms
113,408 KB
testcase_34 AC 396 ms
96,128 KB
testcase_35 AC 320 ms
97,536 KB
testcase_36 AC 557 ms
106,112 KB
testcase_37 AC 893 ms
110,756 KB
testcase_38 AC 171 ms
82,048 KB
testcase_39 AC 285 ms
95,872 KB
testcase_40 AC 289 ms
95,616 KB
testcase_41 AC 273 ms
109,440 KB
testcase_42 AC 265 ms
109,824 KB
testcase_43 AC 316 ms
120,192 KB
testcase_44 AC 320 ms
119,680 KB
testcase_45 AC 320 ms
119,936 KB
testcase_46 AC 347 ms
114,560 KB
testcase_47 AC 441 ms
119,936 KB
testcase_48 AC 576 ms
114,432 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