結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2024-07-02 21:57:02 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 80 ms / 5,000 ms |
| + 117µs | |
| コード長 | 363 bytes |
| 記録 | |
| コンパイル時間 | 223 ms |
| コンパイル使用メモリ | 96,232 KB |
| 実行使用メモリ | 84,736 KB |
| 最終ジャッジ日時 | 2026-08-04 06:45:31 |
| 合計ジャッジ時間 | 4,428 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from collections import deque
N = int(input())
dists = [-1] * (N+1)
dists[1] = 1
q = deque([1])
while q:
x = q.popleft()
d = x.bit_count()
l = x-d
if l > 0 and dists[l] == -1:
dists[l] = dists[x] + 1
q.append(l)
r = x+d
if r <= N and dists[r] == -1:
dists[r] = dists[x] + 1
q.append(r)
print(dists[N])
norioc