結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
いまり💣🍠
|
| 提出日時 | 2024-06-07 06:14:00 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 506 bytes |
| 記録 | |
| コンパイル時間 | 331 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 64,256 KB |
| 最終ジャッジ日時 | 2026-05-30 22:58:45 |
| 合計ジャッジ時間 | 2,733 ms |
|
ジャッジサーバーID (参考情報) |
<nil> / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 15 |
ソースコード
from collections import deque
N = int(input())
todo = deque()
todo.append(0)
counts = [0] * N
counts[0] = 1
while len(todo) > 0:
i = todo.pop()
if i == N - 1:
print(counts[i])
exit()
back = i - (i + 1).bit_count()
front = i + (i + 1).bit_count()
if back >= 0 and counts[back] == 0:
counts[back] = counts[i] + 1
todo.append(back)
if front < N and counts[front] == 0:
counts[front] = counts[i] + 1
todo.append(front)
print(-1)
いまり💣🍠