結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-11 06:17:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 880 bytes |
| コンパイル時間 | 327 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2024-10-12 20:08:20 |
| 合計ジャッジ時間 | 3,122 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 4 RE * 16 |
ソースコード
def go(target,current,path):
if current==target:
# print('DONE!')
return
# print('debug',current, Z)
x=bin(current)[2:].count('1')
f,b=current+x,current-x
if 0<f<=N or 0<b<=N:
if f in Z and b in Z:
return
else:
if 0<f<=N and f not in Z:
Z.add(f)
path.append(f)
go(N,f,path)
R.append(path)
if path[-1]==target:return
if 0<b<=N and b not in Z:
Z.add(b)
path.append(b)
go(N,b,path)
R.append(path)
if path[-1]==target:return
else:
return
# f,b=current
return
N=int(input())
A=[x for x in range(1,N+1)]
Z={1}
current=1
path=[1]
R=[]
go(N,current,path)
#print(Z,R)
print(min([len(r) if N in r else -1 for r in R ]))