結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
motor_radial
|
| 提出日時 | 2019-08-31 20:33:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,064 ms / 5,000 ms |
| コード長 | 421 bytes |
| コンパイル時間 | 117 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-07-01 09:29:28 |
| 合計ジャッジ時間 | 13,810 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from collections import deque
N=int(input())
Node=(1,1)
Route=[1]
Q=deque([Node])
while Q:
n,count=Q.popleft()
if n==N:
print(count);exit()
mass_2=bin(n).count("1")
if n+mass_2<=N and n+mass_2 not in Route:
Route.append(n+mass_2)
Q.append((n+mass_2,count+1))
if n-mass_2>1 and n-mass_2 not in Route:
Route.append(n-mass_2)
Q.append((n-mass_2,count+1))
print(-1)
motor_radial