結果

問題 No.3 ビットすごろく
ユーザー jamadjamad
提出日時 2017-08-13 05:27:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 227 ms / 5,000 ms
コード長 241 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 61,224 KB
最終ジャッジ日時 2023-09-14 00:47:36
合計ジャッジ時間 4,541 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,304 KB
testcase_01 AC 15 ms
8,164 KB
testcase_02 AC 14 ms
8,108 KB
testcase_03 AC 33 ms
11,972 KB
testcase_04 AC 17 ms
8,764 KB
testcase_05 AC 87 ms
24,508 KB
testcase_06 AC 32 ms
12,800 KB
testcase_07 AC 22 ms
9,828 KB
testcase_08 AC 59 ms
18,856 KB
testcase_09 AC 122 ms
34,560 KB
testcase_10 AC 165 ms
45,036 KB
testcase_11 AC 111 ms
30,532 KB
testcase_12 AC 82 ms
23,752 KB
testcase_13 AC 27 ms
10,916 KB
testcase_14 AC 151 ms
42,740 KB
testcase_15 AC 222 ms
59,848 KB
testcase_16 AC 197 ms
53,180 KB
testcase_17 AC 214 ms
58,420 KB
testcase_18 AC 24 ms
10,248 KB
testcase_19 AC 227 ms
61,224 KB
testcase_20 AC 17 ms
8,200 KB
testcase_21 AC 16 ms
8,176 KB
testcase_22 AC 160 ms
43,572 KB
testcase_23 AC 223 ms
61,036 KB
testcase_24 AC 223 ms
61,096 KB
testcase_25 AC 223 ms
59,864 KB
testcase_26 AC 15 ms
8,172 KB
testcase_27 AC 28 ms
11,408 KB
testcase_28 AC 193 ms
51,460 KB
testcase_29 AC 113 ms
31,416 KB
testcase_30 AC 15 ms
8,232 KB
testcase_31 AC 16 ms
8,204 KB
testcase_32 AC 99 ms
28,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def upd(x,t):
 if 0<x<=N and A[x]==[]:Q.append(x);A[x]=A[t]+[x]
    
def bfs():
 while Q:
  t=Q.pop(0)
  if t==N:return len(A[N])
  c=bin(t).count('1');upd(t+c,t);upd(t-c,t)
 return -1

N=int(input())
A=[[]]*10001
A[1]=[1]
Q=[1]
print(bfs())
0