結果
問題 | No.3 ビットすごろく |
ユーザー | kjnho |
提出日時 | 2017-02-19 13:48:23 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 1,541 ms / 5,000 ms |
コード長 | 991 bytes |
コンパイル時間 | 105 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 69,660 KB |
最終ジャッジ日時 | 2024-07-01 08:18:20 |
合計ジャッジ時間 | 56,534 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
外部呼び出し有り |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,470 ms
68,944 KB |
testcase_01 | AC | 1,473 ms
68,932 KB |
testcase_02 | AC | 1,473 ms
68,948 KB |
testcase_03 | AC | 1,506 ms
69,076 KB |
testcase_04 | AC | 1,498 ms
68,956 KB |
testcase_05 | AC | 1,493 ms
69,208 KB |
testcase_06 | AC | 1,493 ms
69,316 KB |
testcase_07 | AC | 1,479 ms
69,064 KB |
testcase_08 | AC | 1,504 ms
69,488 KB |
testcase_09 | AC | 1,506 ms
69,252 KB |
testcase_10 | AC | 1,497 ms
69,392 KB |
testcase_11 | AC | 1,493 ms
69,104 KB |
testcase_12 | AC | 1,492 ms
69,200 KB |
testcase_13 | AC | 1,488 ms
68,952 KB |
testcase_14 | AC | 1,500 ms
69,144 KB |
testcase_15 | AC | 1,518 ms
69,660 KB |
testcase_16 | AC | 1,516 ms
69,044 KB |
testcase_17 | AC | 1,506 ms
69,312 KB |
testcase_18 | AC | 1,490 ms
68,952 KB |
testcase_19 | AC | 1,509 ms
69,548 KB |
testcase_20 | AC | 1,490 ms
69,308 KB |
testcase_21 | AC | 1,509 ms
68,932 KB |
testcase_22 | AC | 1,519 ms
69,184 KB |
testcase_23 | AC | 1,522 ms
69,416 KB |
testcase_24 | AC | 1,531 ms
69,056 KB |
testcase_25 | AC | 1,541 ms
69,172 KB |
testcase_26 | AC | 1,535 ms
69,184 KB |
testcase_27 | AC | 1,532 ms
68,928 KB |
testcase_28 | AC | 1,528 ms
69,324 KB |
testcase_29 | AC | 1,533 ms
69,272 KB |
testcase_30 | AC | 1,512 ms
69,192 KB |
testcase_31 | AC | 1,501 ms
69,184 KB |
testcase_32 | AC | 1,512 ms
69,220 KB |
ソースコード
import re from scipy import integrate from operator import itemgetter from collections import defaultdict as dd from collections import Counter from collections import deque import numpy as np import fractions import itertools import math import heapq from heapq import heappop, heappush, heapify from copy import deepcopy as dcopy N = int(input()) # N = 5000 stack = deque() stack.append((1, 0)) # count, position, arrived, root D = [1] + [float("inf")]*(N-1) # saitankyorimap flag = False while len(stack) != 0: count, position = stack.popleft() number = position + 1 if number == N: print(count) flag = True break move_size = bin(number).count("1") for move in (move_size, - move_size): new_position = position + move new_count = count + 1 if (0 <= new_position <= N-1) and D[new_position] > count: D[new_position] = count stack.append((new_count, new_position)) if not flag: print(-1)