結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-11 13:08:10 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 37 ms / 5,000 ms |
| + 152µs | |
| コード長 | 337 bytes |
| 記録 | |
| コンパイル時間 | 704 ms |
| コンパイル使用メモリ | 80,700 KB |
| 実行使用メモリ | 65,408 KB |
| 最終ジャッジ日時 | 2026-10-11 13:08:30 |
| 合計ジャッジ時間 | 3,684 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from collections import deque
N = int(input())
dist = [-1]*(N + 1)
dist[1] = 1
que = deque()
que.append(1)
while que:
pos = que.popleft()
b = pos.bit_count()
for j in [-b, b]:
nex = pos + j
if 1 <= nex <= N and dist[nex] == -1:
dist[nex] = dist[pos] + 1
que.append(nex)
print(dist[-1])