結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-07 11:43:03 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,045 bytes |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 12,928 KB |
| 最終ジャッジ日時 | 2024-11-29 04:53:49 |
| 合計ジャッジ時間 | 2,324 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 15 |
ソースコード
# -*- coding: utf-8 -*-
import sys
def make_one_count_of_binary_digit(N):
l = []
for i in range(0, N + 1):
l.append(bin(i).count('1'))
return l
def move_idx(p_list, idx, N):
p_list[idx]['right_move'] = True
if idx + binary_digit_one_list[idx] <= N:
return p_list, idx + binary_digit_one_list[idx]
p_list[idx]['left_move'] = True
return p_list, idx - binary_digit_one_list[idx]
if __name__ == '__main__':
N = int(input())
possibility_list = [{'left_move': None, 'right_move': None} for _ in range(0, N + 1)]
binary_digit_one_list = make_one_count_of_binary_digit(N)
flag = True
idx = 1
count = 1
while flag:
if idx == N:
print(count)
flag = False
sys.exit()
if possibility_list[idx]['left_move'] and possibility_list[idx]['right_move']:
print(-1)
flag = False
sys.exit()
else:
possibility_list, idx = move_idx(possibility_list, idx, N)
count += 1