結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
togatoga
|
| 提出日時 | 2015-08-15 07:29:14 |
| 言語 | PyPy2 (7.3.20) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 5,000 ms |
| + 385µs | |
| コード長 | 436 bytes |
| 記録 | |
| コンパイル時間 | 66 ms |
| コンパイル使用メモリ | 81,024 KB |
| 実行使用メモリ | 85,760 KB |
| 最終ジャッジ日時 | 2026-07-17 18:53:37 |
| 合計ジャッジ時間 | 4,656 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from Queue import Queue
import sys
N = input()
q = Queue()
q.put([1, 0])
visit = set()
while (q.empty() == False):
pos = q.get()
if (pos[0] <= 0 or pos[0] >= N + 1):
continue
if (pos[0] == N):
print pos[1] + 1
sys.exit(0)
if (pos[0] in visit):
continue
visit.add(pos[0])
x = bin(pos[0]).count("1")
q.put([pos[0] + x, pos[1] + 1])
q.put([pos[0] - x, pos[1] + 1])
print -1
togatoga