結果
問題 |
No.1473 おでぶなおばけさん
|
ユーザー |
![]() |
提出日時 | 2021-04-09 21:51:47 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 810 bytes |
コンパイル時間 | 366 ms |
コンパイル使用メモリ | 81,916 KB |
実行使用メモリ | 146,076 KB |
最終ジャッジ日時 | 2024-06-25 05:08:48 |
合計ジャッジ時間 | 29,692 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 45 TLE * 2 |
ソースコード
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 w <= z and reach[y] == float("Inf"): 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))