結果
| 問題 |
No.3 ビットすごろく
|
| ユーザー |
|
| 提出日時 | 2019-01-08 20:52:15 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 533 bytes |
| コンパイル時間 | 202 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 33,664 KB |
| 最終ジャッジ日時 | 2024-11-24 00:47:35 |
| 合計ジャッジ時間 | 81,983 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 TLE * 11 |
ソースコード
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()
reach[node[0] - 1] = 1
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))
print(-1)