結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-03 14:02:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,044 bytes |
| コンパイル時間 | 369 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-12-24 19:09:24 |
| 合計ジャッジ時間 | 2,490 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 33 |
ソースコード
def count_one(d):
b = 0b1
count = 0
for i in range(16):
if d & b:
count += 1
b = b << 1
return count
def func(current_index, current_nest, goal_index):
if current_index == goal_index:
if (nest_list[n-1] == -1) or (nest_list[n-1] > current_nest):
nest_list[n-1] = current_nest
return
if nest_list[current_index] is not goal_index:
if nest_list[current_index] > current_nest:
nest_list[current_index] = current_nest
else :
return
else :
nest_list[current_index] = current_nest
gap_index = count_one(current_index+1)
front_index = current_index - gap_index
back_index = current_index + gap_index
if front_index > 0:
func(front_index, current_nest + 1, goal_index)
if back_index <= goal_index:
func(back_index, current_nest + 1, goal_index)
n = map(int, input().splite())
nest_list = [n] * n
nest_list[n-1] = -1
func(0, 1, n-1)
print(nest_list[n-1])