結果

問題 No.3 ビットすごろく
コンテスト
ユーザー しゅらにるーとに
提出日時 2024-12-14 23:40:11
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 881 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,750 ms
コンパイル使用メモリ 201,472 KB
最終ジャッジ日時 2026-01-04 18:45:45
合計ジャッジ時間 2,446 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc-15/include/c++/15.2.0/bits/stl_algobase.h:76,
         次から読み込み:  /usr/local/gcc-15/include/c++/15.2.0/algorithm:62,
         次から読み込み:  /usr/local/gcc-15/include/c++/15.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:53,
         次から読み込み:  main.cpp:1:
/usr/local/gcc-15/include/c++/15.2.0/bit: In instantiation of ‘constexpr int std::__popcount(_Tp) [with _Tp = int]’:
main.cpp:29:18:   required from here
   29 |                 if(v+__popcount(v)<N+1&&vi[v+__popcount(v)]==-1)vi[v+__popcount(v)]=vi[v]+1,q.push(v+__popcount(v));
      |                      ~~~~~~~~~~^~~
/usr/local/gcc-15/include/c++/15.2.0/bit:308:34: エラー: argument 1 in call to function ‘__builtin_popcountg’ has signed type
  308 |       return __builtin_popcountg(__x);
      |                                  ^~~

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#include <atcoder/all>
#ifdef LOCAL
#include <debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif
using namespace atcoder;
using mint=modint1000000007;
using namespace std;
using ll=long long;
using ul=unsigned long long;
int dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
int dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
using Graph=vector<vector<int>>;
ll op(ll a,ll b){return min(a,b);}
ll e(){return 2e9;}
int main(){
	int N;
	cin>>N;
	vector<int>vi(N+1,-1);
	queue<int>q;
	q.push(1);
	vi[1]=1;
	while(!q.empty()){
		int v=q.front();
		q.pop();
		if(v+__popcount(v)<N+1&&vi[v+__popcount(v)]==-1)vi[v+__popcount(v)]=vi[v]+1,q.push(v+__popcount(v));
		if(v-__popcount(v)>0&&vi[v-__popcount(v)]==-1)vi[v-__popcount(v)]=vi[v]+1,q.push(v-__popcount(v));
	}
	cout<<vi[N]<<endl;
}	
0