結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
kanoekakihito
|
| 提出日時 | 2016-09-24 00:42:00 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 573 bytes |
| 記録 | |
| コンパイル時間 | 794 ms |
| コンパイル使用メモリ | 20,828 KB |
| 実行使用メモリ | 15,388 KB |
| 最終ジャッジ日時 | 2026-05-12 14:31:31 |
| 合計ジャッジ時間 | 4,881 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 15 |
ソースコード
n = int(input())
prev = [[1, []]]
fastest = dict()
end_flag = False
c = 1
while len(prev) != 0:
next = []
for p in prev:
if p[0] == n:
print(c)
end_flag = True
break
b = bin(p[0])[2:].count("1")
if b + p[0] > n:
next_place = p[0] - b
else:
next_place = p[0] + b
if next_place not in fastest or fastest[next_place] <= c:
if 1 <= next_place <= n and not next_place in p[1]:
fastest[next_place] = c
next.append([next_place, p[1] + [p[0]]])
if end_flag:
break
c += 1
prev = sorted(next, key = lambda x: x[0])
else:
print(-1)
kanoekakihito