結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
定期定期
|
| 提出日時 | 2024-11-11 01:37:44 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 796 bytes |
| コンパイル時間 | 351 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-11-11 01:37:47 |
| 合計ジャッジ時間 | 2,905 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 15 |
ソースコード
import sys
sys.setrecursionlimit(10**6)
n = int(input())
point_list = [-1 for _ in range(n+1)]
point_list[1] = 1
def move(point):
left = point - point.bit_count()
right = point + point.bit_count()
move_left = False
move_right = False
if left > 0:
if point_list[left] == -1:
point_list[left] = point_list[point] + 1
# move(left)
move_left = True
if right < n + 1:
if point_list[right] == -1:
point_list[right] = point_list[point] + 1
# move(right)
move_right = True
if move_left and move_right:
if left < n:
move(right)
move(left)
else:
move(left)
move(right)
elif move_left:
move(left)
elif move_right:
move(right)
move(1)
if point_list[n] != -1 :
print(point_list[n])
else :
print(-1)
定期定期