結果

問題 No.3 ビットすごろく
ユーザー ABKZABKZ
提出日時 2021-10-28 18:33:48
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 103 ms / 5,000 ms
コード長 404 bytes
コンパイル時間 2,159 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 78,908 KB
最終ジャッジ日時 2023-07-29 05:54:46
合計ジャッジ時間 5,237 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,616 KB
testcase_01 AC 73 ms
71,148 KB
testcase_02 AC 72 ms
71,356 KB
testcase_03 AC 92 ms
76,544 KB
testcase_04 AC 77 ms
75,484 KB
testcase_05 AC 91 ms
76,876 KB
testcase_06 AC 88 ms
76,852 KB
testcase_07 AC 85 ms
76,716 KB
testcase_08 AC 89 ms
76,928 KB
testcase_09 AC 95 ms
78,236 KB
testcase_10 AC 100 ms
78,324 KB
testcase_11 AC 93 ms
76,880 KB
testcase_12 AC 93 ms
77,032 KB
testcase_13 AC 87 ms
76,740 KB
testcase_14 AC 98 ms
78,308 KB
testcase_15 AC 100 ms
78,704 KB
testcase_16 AC 99 ms
78,380 KB
testcase_17 AC 99 ms
78,700 KB
testcase_18 AC 86 ms
76,824 KB
testcase_19 AC 103 ms
78,908 KB
testcase_20 AC 74 ms
71,448 KB
testcase_21 AC 74 ms
71,360 KB
testcase_22 AC 97 ms
78,148 KB
testcase_23 AC 99 ms
78,576 KB
testcase_24 AC 97 ms
78,672 KB
testcase_25 AC 98 ms
78,800 KB
testcase_26 AC 72 ms
71,440 KB
testcase_27 AC 87 ms
76,820 KB
testcase_28 AC 98 ms
78,364 KB
testcase_29 AC 94 ms
76,964 KB
testcase_30 AC 72 ms
71,384 KB
testcase_31 AC 77 ms
71,352 KB
testcase_32 AC 96 ms
76,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

jmp_to = {x: [x-d, x+d] for x,d in [[x, bin(x).count("1")] for x in range(1,N)]}

pos = {1}
passed = set()
cnt = 1
while len(pos) > 0:
    if N in pos:
        break
    passed.update(pos)
    new_pos = set()
    for i in pos:
        if i > 0 and i < N:
            new_pos.update(jmp_to[i])
    new_pos = new_pos - passed
    pos = new_pos
    cnt += 1
else:
    cnt = -1

print(cnt)
0