結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2021-04-03 14:03:13 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,044 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-12-24 19:11:56 |
合計ジャッジ時間 | 2,259 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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])