結果
| 問題 |
No.1473 おでぶなおばけさん
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-06-10 22:07:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,322 ms / 2,000 ms |
| コード長 | 827 bytes |
| コンパイル時間 | 481 ms |
| コンパイル使用メモリ | 82,636 KB |
| 実行使用メモリ | 152,488 KB |
| 最終ジャッジ日時 | 2025-06-10 22:08:13 |
| 合計ジャッジ時間 | 20,294 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 |
ソースコード
from collections import defaultdict, deque
def calc(weight: int) -> int:
q = deque([(0, 0)])
used = set()
while q:
v, step = q.popleft()
if v == N-1: return step
if v in used: continue
used.add(v)
for to, d in adj[v]:
if weight > d: continue
if to in used: continue
q.append((to, step+1))
return -1
N, M = map(int, input().split())
adj = defaultdict(list)
for _ in range(M):
s, t, d = map(int, input().split())
s -= 1
t -= 1
adj[s].append((t, d))
adj[t].append((s, d))
lo = 1
hi = 10**9
limit = 0
step = 0
while lo <= hi:
m = (lo + hi) // 2
s = calc(m)
if s > 0:
if limit < m:
limit = m
step = s
lo = m + 1
else:
hi = m - 1
print(limit, step)
norioc