結果
問題 | No.3 ビットすごろく |
ユーザー | maburoe |
提出日時 | 2019-05-28 15:36:02 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 195 ms / 5,000 ms |
コード長 | 762 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 10,924 KB |
実行使用メモリ | 9,420 KB |
最終ジャッジ日時 | 2023-09-14 01:18:06 |
合計ジャッジ時間 | 4,238 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,792 KB |
testcase_01 | AC | 16 ms
7,880 KB |
testcase_02 | AC | 17 ms
7,944 KB |
testcase_03 | AC | 35 ms
8,476 KB |
testcase_04 | AC | 20 ms
8,136 KB |
testcase_05 | AC | 73 ms
8,828 KB |
testcase_06 | AC | 35 ms
8,396 KB |
testcase_07 | AC | 27 ms
8,316 KB |
testcase_08 | AC | 61 ms
8,616 KB |
testcase_09 | AC | 111 ms
8,880 KB |
testcase_10 | AC | 157 ms
9,268 KB |
testcase_11 | AC | 98 ms
8,808 KB |
testcase_12 | AC | 72 ms
8,840 KB |
testcase_13 | AC | 29 ms
8,352 KB |
testcase_14 | AC | 139 ms
9,172 KB |
testcase_15 | AC | 167 ms
9,376 KB |
testcase_16 | AC | 177 ms
9,356 KB |
testcase_17 | AC | 188 ms
9,420 KB |
testcase_18 | AC | 29 ms
8,256 KB |
testcase_19 | AC | 195 ms
9,260 KB |
testcase_20 | AC | 19 ms
8,216 KB |
testcase_21 | AC | 16 ms
7,952 KB |
testcase_22 | AC | 141 ms
9,128 KB |
testcase_23 | AC | 169 ms
9,288 KB |
testcase_24 | AC | 189 ms
9,408 KB |
testcase_25 | AC | 189 ms
9,416 KB |
testcase_26 | AC | 16 ms
7,768 KB |
testcase_27 | AC | 34 ms
8,420 KB |
testcase_28 | AC | 176 ms
9,340 KB |
testcase_29 | AC | 104 ms
8,816 KB |
testcase_30 | AC | 17 ms
7,796 KB |
testcase_31 | AC | 17 ms
7,800 KB |
testcase_32 | AC | 88 ms
8,792 KB |
ソースコード
import sys sys.setrecursionlimit(10000) goal = int(input()) stepped = dict() maybe_answers = set() def step(position, count): if position in stepped: if count < stepped[position]: stepped[position] = count else: return else: stepped[position] = count if position not in range(1, goal + 1): return if len(maybe_answers) > 0 and count > min(maybe_answers): return if position == goal: maybe_answers.add(count) return position_bin = bin(position) step(position + position_bin.count('1'), count + 1) step(position - position_bin.count('1'), count + 1) step(1, 1) if len(maybe_answers) == 0: print('-1') else: print(min(maybe_answers))