結果
問題 | No.3 ビットすごろく |
ユーザー |
![]() |
提出日時 | 2024-06-07 06:14:00 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 506 bytes |
コンパイル時間 | 474 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 64,128 KB |
最終ジャッジ日時 | 2024-12-25 05:56:19 |
合計ジャッジ時間 | 3,426 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
ソースコード
from collections import dequeN = int(input())todo = deque()todo.append(0)counts = [0] * Ncounts[0] = 1while 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] + 1todo.append(back)if front < N and counts[front] == 0:counts[front] = counts[i] + 1todo.append(front)print(-1)