結果

問題 No.3 ビットすごろく
ユーザー piconic_Xpiconic_X
提出日時 2016-08-13 21:48:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 754 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 23,244 KB
最終ジャッジ日時 2024-04-25 06:25:02
合計ジャッジ時間 18,532 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,624 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 48 ms
11,008 KB
testcase_04 AC 33 ms
10,752 KB
testcase_05 AC 286 ms
11,520 KB
testcase_06 AC 51 ms
10,880 KB
testcase_07 AC 39 ms
10,752 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 238 ms
11,520 KB
testcase_13 AC 44 ms
10,880 KB
testcase_14 AC 3,679 ms
17,896 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def search(N):
    history = set([])
    queue = [0]
    res = -1
    time = 1
    while queue != []:
        next_queue = []
        for pos in queue:
            if pos == N-1:
                res = time
                break
            else:
                history.add(pos)
                val = pos+1
                bitnum = bin(val).count('1')
                posR = pos + bitnum
                posL = pos - bitnum
                if posR < N and not posR in history:
                    next_queue.append(posR)
                if posL > 0 and not posL in history:
                    next_queue.append(posL)
        time += 1
        queue = next_queue
    return res

def main():
    N = int(input())
    res = search(N)
    print(res)

main()
0