結果

問題 No.3 ビットすごろく
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-11-28 07:20:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 543 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 74,748 KB
最終ジャッジ日時 2024-04-15 09:41:20
合計ジャッジ時間 3,668 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
57,192 KB
testcase_01 AC 48 ms
55,488 KB
testcase_02 AC 49 ms
56,852 KB
testcase_03 AC 64 ms
68,580 KB
testcase_04 AC 56 ms
64,492 KB
testcase_05 AC 71 ms
71,360 KB
testcase_06 AC 65 ms
68,228 KB
testcase_07 AC 61 ms
66,700 KB
testcase_08 AC 65 ms
70,836 KB
testcase_09 AC 67 ms
71,820 KB
testcase_10 AC 68 ms
71,884 KB
testcase_11 AC 66 ms
71,208 KB
testcase_12 AC 65 ms
70,864 KB
testcase_13 AC 65 ms
67,780 KB
testcase_14 AC 119 ms
72,860 KB
testcase_15 AC 87 ms
73,668 KB
testcase_16 AC 68 ms
73,264 KB
testcase_17 AC 69 ms
74,236 KB
testcase_18 AC 65 ms
69,168 KB
testcase_19 AC 71 ms
73,440 KB
testcase_20 AC 50 ms
57,664 KB
testcase_21 AC 48 ms
55,652 KB
testcase_22 AC 68 ms
72,464 KB
testcase_23 AC 69 ms
74,068 KB
testcase_24 AC 68 ms
74,628 KB
testcase_25 AC 68 ms
74,748 KB
testcase_26 AC 50 ms
56,324 KB
testcase_27 AC 66 ms
68,772 KB
testcase_28 AC 68 ms
73,788 KB
testcase_29 AC 67 ms
71,924 KB
testcase_30 AC 50 ms
56,560 KB
testcase_31 AC 49 ms
56,720 KB
testcase_32 AC 67 ms
71,848 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