結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
piconic_X
|
| 提出日時 | 2016-08-13 21:48:22 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 754 bytes |
| 記録 | |
| コンパイル時間 | 479 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 35,660 KB |
| 最終ジャッジ日時 | 2026-05-08 00:05:29 |
| 合計ジャッジ時間 | 17,242 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 12 TLE * 5 |
ソースコード
def search(N):
history = set([])
queue = [0]
res = -1
time = 1
while queue != []:
next_queue = []
for pos in queue:
if pos == N-1:
res = time
break
else:
history.add(pos)
val = pos+1
bitnum = bin(val).count('1')
posR = pos + bitnum
posL = pos - bitnum
if posR < N and not posR in history:
next_queue.append(posR)
if posL > 0 and not posL in history:
next_queue.append(posL)
time += 1
queue = next_queue
return res
def main():
N = int(input())
res = search(N)
print(res)
main()
piconic_X