結果

問題 No.3 ビットすごろく
ユーザー syunsukesyunsuke
提出日時 2019-06-30 17:12:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 17,468 KB
最終ジャッジ日時 2023-09-20 12:47:24
合計ジャッジ時間 12,005 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,288 KB
testcase_01 AC 17 ms
8,180 KB
testcase_02 AC 17 ms
8,316 KB
testcase_03 AC 343 ms
8,620 KB
testcase_04 AC 54 ms
8,400 KB
testcase_05 AC 3,040 ms
10,852 KB
testcase_06 AC 357 ms
8,844 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
G=[[]for i in range(N+1)]
T=[10**20 for i in range(N+1)]
G[1].append(2)
for i in range(2,N+1):
    cnt=0
    n=i
    for j in range(14):
        if n//(2**(13-j))==1:
            cnt+=1
        n%=(2**(13-j))
        #print(i,n,cnt)
    G[i].append(i+cnt)
    G[i].append(i-cnt)
#print(G)
ans=1
L=[0 for i in range(N+1)]
L[1]=1
#print(L)
import heapq
Q=[]
heapq.heapify(Q)
heapq.heappush(Q,[2,2])
for i in range(10**7):
    if len(Q)==0:
        break
    else:
        L[Q[0][1]]=Q[0][0]
        S=Q[0][1]
        Le=Q[0][0]
        heapq.heappop(Q)
        #print(G[S])
        #print(L)
        if G[S][0]<=len(L)-1:
            if L[G[S][0]]==0:
                heapq.heappush(Q,[Le+1,G[S][0]])
        if G[S][1]<=len(L)-1:
            if L[G[S][1]]==0:
                heapq.heappush(Q,[Le+1,G[S][1]])
#print(G)
#print(L)
if L[N]!=0:
    print(L[N])
else:
    print(-1)
0