結果
問題 | No.3 ビットすごろく |
ユーザー | dn6049949 |
提出日時 | 2022-04-15 22:25:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 126 ms / 5,000 ms |
コード長 | 914 bytes |
コンパイル時間 | 480 ms |
コンパイル使用メモリ | 86,896 KB |
実行使用メモリ | 77,552 KB |
最終ジャッジ日時 | 2023-08-26 08:13:37 |
合計ジャッジ時間 | 5,162 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 89 ms
71,772 KB |
testcase_01 | AC | 91 ms
71,740 KB |
testcase_02 | AC | 88 ms
71,268 KB |
testcase_03 | AC | 126 ms
77,304 KB |
testcase_04 | AC | 100 ms
76,988 KB |
testcase_05 | AC | 97 ms
77,488 KB |
testcase_06 | AC | 97 ms
77,240 KB |
testcase_07 | AC | 100 ms
77,160 KB |
testcase_08 | AC | 98 ms
76,852 KB |
testcase_09 | AC | 97 ms
77,500 KB |
testcase_10 | AC | 104 ms
77,300 KB |
testcase_11 | AC | 95 ms
77,552 KB |
testcase_12 | AC | 98 ms
77,452 KB |
testcase_13 | AC | 99 ms
77,036 KB |
testcase_14 | AC | 100 ms
77,260 KB |
testcase_15 | AC | 96 ms
77,292 KB |
testcase_16 | AC | 100 ms
77,452 KB |
testcase_17 | AC | 98 ms
77,316 KB |
testcase_18 | AC | 94 ms
77,320 KB |
testcase_19 | AC | 100 ms
77,364 KB |
testcase_20 | AC | 88 ms
72,188 KB |
testcase_21 | AC | 86 ms
71,364 KB |
testcase_22 | AC | 100 ms
77,380 KB |
testcase_23 | AC | 100 ms
77,272 KB |
testcase_24 | AC | 100 ms
77,312 KB |
testcase_25 | AC | 102 ms
77,392 KB |
testcase_26 | AC | 86 ms
71,320 KB |
testcase_27 | AC | 95 ms
77,324 KB |
testcase_28 | AC | 102 ms
77,408 KB |
testcase_29 | AC | 97 ms
77,272 KB |
testcase_30 | AC | 90 ms
71,280 KB |
testcase_31 | AC | 86 ms
71,796 KB |
testcase_32 | AC | 101 ms
77,504 KB |
ソースコード
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def IR(n): return [I() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 def main(): def popcount(n): return bin(n).count("1") n = I() d = [float("inf")]*(n+1) d[1] = 1 q = deque([1]) while q: x = q.popleft() dx = popcount(x) nd = d[x]+1 for nx in (x-dx,x+dx): if 1 <= nx <= n and nd < d[nx]: d[nx] = nd q.append(nx) ans = d[n] if ans == float("inf"): ans = -1 print(ans) return if __name__ == "__main__": main()