結果
| 問題 |
No.3 ビットすごろく
|
| ユーザー |
|
| 提出日時 | 2018-12-01 18:10:19 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 483 bytes |
| コンパイル時間 | 269 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-06-27 00:01:48 |
| 合計ジャッジ時間 | 2,210 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 22 |
ソースコード
from collections import deque
def convert_bit(x):
return bin(x).count("1")
N = int(input())
q = deque([1])
reach =[0 for i in range(N)]
while q != deque([]):
pos = q.popleft()
reach[pos-1] = 1
if pos == N:
print(N)
exit()
move = convert_bit(pos)
for m in [move,-move]:
next_pos = m + pos
if not 1 <= next_pos <= N:
continue
if reach[next_pos - 1] == 1:
q.append(next_pos)
print(-1)