結果

問題 No.1473 おでぶなおばけさん
ユーザー convexineqconvexineq
提出日時 2021-04-09 21:51:47
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,237 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 110,612 KB
最終ジャッジ日時 2023-09-07 10:58:16
合計ジャッジ時間 22,474 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
71,628 KB
testcase_01 AC 89 ms
71,588 KB
testcase_02 AC 643 ms
103,232 KB
testcase_03 AC 441 ms
105,932 KB
testcase_04 AC 498 ms
91,680 KB
testcase_05 AC 231 ms
81,464 KB
testcase_06 AC 753 ms
98,704 KB
testcase_07 AC 618 ms
103,156 KB
testcase_08 AC 1,005 ms
102,600 KB
testcase_09 AC 578 ms
107,420 KB
testcase_10 AC 257 ms
86,164 KB
testcase_11 AC 270 ms
86,148 KB
testcase_12 AC 252 ms
86,288 KB
testcase_13 AC 191 ms
82,980 KB
testcase_14 AC 172 ms
80,576 KB
testcase_15 AC 236 ms
85,744 KB
testcase_16 AC 215 ms
85,160 KB
testcase_17 AC 133 ms
77,624 KB
testcase_18 AC 141 ms
79,068 KB
testcase_19 AC 284 ms
86,168 KB
testcase_20 AC 408 ms
99,744 KB
testcase_21 AC 436 ms
94,144 KB
testcase_22 AC 302 ms
106,880 KB
testcase_23 AC 275 ms
106,748 KB
testcase_24 AC 272 ms
102,640 KB
testcase_25 AC 1,208 ms
99,692 KB
testcase_26 AC 1,237 ms
99,468 KB
testcase_27 AC 244 ms
82,996 KB
testcase_28 AC 797 ms
102,840 KB
testcase_29 AC 478 ms
95,884 KB
testcase_30 AC 631 ms
96,028 KB
testcase_31 AC 527 ms
110,612 KB
testcase_32 AC 485 ms
101,340 KB
testcase_33 AC 397 ms
97,392 KB
testcase_34 AC 277 ms
89,480 KB
testcase_35 AC 253 ms
87,700 KB
testcase_36 AC 405 ms
90,084 KB
testcase_37 AC 638 ms
97,640 KB
testcase_38 AC 179 ms
80,312 KB
testcase_39 AC 223 ms
84,976 KB
testcase_40 AC 216 ms
85,052 KB
testcase_41 AC 211 ms
87,908 KB
testcase_42 AC 206 ms
88,120 KB
testcase_43 AC 251 ms
98,300 KB
testcase_44 AC 243 ms
98,276 KB
testcase_45 AC 251 ms
98,288 KB
testcase_46 AC 327 ms
98,720 KB
testcase_47 AC 401 ms
97,552 KB
testcase_48 AC 385 ms
97,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def check(x):
    dist = [-1]*n
    dist[0] = 0
    q = deque([0])
    while q:
        v = q.popleft()
        for b,w in g[v]:
            if dist[b] == -1 and x <= w:
                dist[b] = dist[v] + 1
                q.append(b)
    if dist[-1] == -1:
        return False,-1
    else:
        return True, dist[-1]

n,m = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a,b,w = map(int,input().split())
    g[a-1].append((b-1,w))
    g[b-1].append((a-1,w))

ok = 0
ng = 10**9+1
val = -1
while ng-ok > 1:
    mid = (ok+ng)//2
    tf,v = check(mid)
    if tf:
        ok = mid
        val = v
    else:
        ng = mid
print(ok,val)
0