結果
| 問題 |
No.3 ビットすごろく
|
| ユーザー |
|
| 提出日時 | 2020-06-06 00:11:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 770 bytes |
| コンパイル時間 | 93 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,904 KB |
| 最終ジャッジ日時 | 2024-12-17 19:54:01 |
| 合計ジャッジ時間 | 2,648 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 WA * 1 |
ソースコード
from collections import deque
import copy
import math
N = int(input())
if N == 1:
print(0)
else:
ans, already, que = 1, set([1]), deque([1])
while len(que) > 0:
nque = deque()
while len(que) > 0:
n = que.popleft()
k, step = n, 0
while k > 0:
step += k % 2
k >>= 1
if n - step >= 1 and n - step not in already:
nque.append(n - step)
already.add(n - step)
if n + step < N and n + step not in already:
nque.append(n + step)
already.add(n + step)
elif n + step == N:
print(ans + 1)
exit()
que = copy.copy(nque)
ans += 1
print(-1)