結果

問題 No.3 ビットすごろく
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-11-28 07:20:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 543 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 78,664 KB
最終ジャッジ日時 2023-07-27 23:18:24
合計ジャッジ時間 6,020 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
72,972 KB
testcase_01 AC 112 ms
73,260 KB
testcase_02 AC 114 ms
73,264 KB
testcase_03 AC 129 ms
78,248 KB
testcase_04 AC 118 ms
77,960 KB
testcase_05 AC 125 ms
78,228 KB
testcase_06 AC 125 ms
78,328 KB
testcase_07 AC 123 ms
78,316 KB
testcase_08 AC 126 ms
78,304 KB
testcase_09 AC 128 ms
78,320 KB
testcase_10 AC 130 ms
78,312 KB
testcase_11 AC 128 ms
78,348 KB
testcase_12 AC 130 ms
78,540 KB
testcase_13 AC 129 ms
78,328 KB
testcase_14 AC 134 ms
78,348 KB
testcase_15 AC 131 ms
78,628 KB
testcase_16 AC 129 ms
78,340 KB
testcase_17 AC 131 ms
78,408 KB
testcase_18 AC 127 ms
78,384 KB
testcase_19 AC 132 ms
78,548 KB
testcase_20 AC 113 ms
73,012 KB
testcase_21 AC 111 ms
73,016 KB
testcase_22 AC 128 ms
78,368 KB
testcase_23 AC 130 ms
78,640 KB
testcase_24 AC 136 ms
78,640 KB
testcase_25 AC 131 ms
78,664 KB
testcase_26 AC 110 ms
72,956 KB
testcase_27 AC 126 ms
78,352 KB
testcase_28 AC 128 ms
78,364 KB
testcase_29 AC 129 ms
78,168 KB
testcase_30 AC 112 ms
72,840 KB
testcase_31 AC 115 ms
72,928 KB
testcase_32 AC 131 ms
78,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from functools import *
from itertools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
dist = defaultdict(lambda: -1)
v = deque()
dist[1]=1
v.append(1)
while v:
    x = v.popleft()
    delta = bin(x).count('1')
    
    e = [x-delta,x+delta]
    
    for ix in e:
        if dist[ix]!=-1:
            continue
        if ix>N:
            continue
        dist[ix]=dist[x]+1
        v.append(ix)
print(dist[N])
0