結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-08 21:10:49 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 541 bytes |
| 記録 | |
| コンパイル時間 | 678 ms |
| コンパイル使用メモリ | 20,828 KB |
| 実行使用メモリ | 30,556 KB |
| 最終ジャッジ日時 | 2026-05-17 20:22:26 |
| 合計ジャッジ時間 | 14,620 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 1 -- * 22 |
ソースコード
from collections import deque
def convert_bit(x):
return bin(x).count("1")
N = int(input())
q = deque([(1,1)])
reach = [0 for i in range(N)]
empty = deque([])
while q != empty:
node = q.popleft()
if node[0] == N:
print(node[1])
exit()
move = convert_bit(node[0])
for m in [move,-move]:
next_pos = m + node[0]
if not 1 <= next_pos <= N:
continue
if reach[next_pos - 1] == 0:
q.append((next_pos,node[1] + 1))
reach[node[0] - 1] = 1
print(-1)