結果

問題 No.1473 おでぶなおばけさん
ユーザー aqua_tenhouaqua_tenhou
提出日時 2022-01-04 19:17:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 727 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 139,084 KB
最終ジャッジ日時 2024-04-22 15:54:57
合計ジャッジ時間 18,987 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,632 KB
testcase_01 AC 38 ms
53,888 KB
testcase_02 AC 727 ms
133,048 KB
testcase_03 AC 391 ms
126,888 KB
testcase_04 AC 369 ms
110,436 KB
testcase_05 AC 173 ms
87,716 KB
testcase_06 AC 617 ms
127,008 KB
testcase_07 AC 500 ms
139,008 KB
testcase_08 AC 687 ms
138,924 KB
testcase_09 AC 453 ms
139,084 KB
testcase_10 AC 249 ms
110,020 KB
testcase_11 AC 291 ms
120,484 KB
testcase_12 AC 264 ms
109,608 KB
testcase_13 AC 182 ms
99,600 KB
testcase_14 AC 161 ms
94,200 KB
testcase_15 AC 254 ms
110,464 KB
testcase_16 AC 240 ms
110,420 KB
testcase_17 AC 85 ms
77,212 KB
testcase_18 AC 93 ms
78,068 KB
testcase_19 AC 273 ms
100,024 KB
testcase_20 AC 354 ms
109,636 KB
testcase_21 AC 512 ms
109,824 KB
testcase_22 AC 322 ms
111,060 KB
testcase_23 AC 279 ms
106,388 KB
testcase_24 AC 276 ms
105,416 KB
testcase_25 AC 316 ms
110,004 KB
testcase_26 AC 337 ms
111,744 KB
testcase_27 AC 162 ms
90,496 KB
testcase_28 AC 311 ms
118,404 KB
testcase_29 AC 282 ms
106,680 KB
testcase_30 AC 339 ms
112,360 KB
testcase_31 AC 580 ms
134,988 KB
testcase_32 AC 611 ms
128,652 KB
testcase_33 AC 395 ms
120,304 KB
testcase_34 AC 240 ms
99,524 KB
testcase_35 AC 249 ms
106,360 KB
testcase_36 AC 241 ms
99,040 KB
testcase_37 AC 265 ms
104,704 KB
testcase_38 AC 113 ms
81,920 KB
testcase_39 AC 234 ms
110,008 KB
testcase_40 AC 252 ms
110,276 KB
testcase_41 AC 241 ms
116,736 KB
testcase_42 AC 230 ms
116,340 KB
testcase_43 AC 299 ms
130,280 KB
testcase_44 AC 310 ms
130,276 KB
testcase_45 AC 304 ms
130,284 KB
testcase_46 AC 245 ms
117,012 KB
testcase_47 AC 291 ms
129,568 KB
testcase_48 AC 315 ms
129,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def is_ok(arg):
    p = l[arg]
    w = BWS(p)
    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)]
se = set([])
for s,t,d in z:
    V[s].append([t,d])
    V[t].append([s,d])
    se.add(d)

l = list(se)
l = [0] + sorted(l) + [10**18]
M = len(l)
ans = meguru_bisect(M, 0)
print(l[ans], BWS(l[ans]))
0