結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-10-14 21:49:44 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 4 ms / 5,000 ms |
| + 76µs | |
| コード長 | 613 bytes |
| 記録 | |
| コンパイル時間 | 2,433 ms |
| コンパイル使用メモリ | 347,924 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-10-14 21:49:51 |
| 合計ジャッジ時間 | 4,893 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;cin>>n;
queue<ll>que;
map<ll,ll>dist;
que.push(1);
dist[1]=1;
while(!que.empty())
{
ll now=que.front();
que.pop();
ll d=__builtin_popcount(now);
for(int i=-1;i<=1;i+=2)
{
ll nex=now+d*i;
if(nex<=0||nex>n||dist.contains(nex))continue;
dist[nex]=dist[now]+1;
que.push(nex);
}
}
if(dist.contains(n))cout<<dist[n]<<endl;
else cout<<-1<<endl;
}