結果

問題 No.3 ビットすごろく
ユーザー CleyLCleyL
提出日時 2020-02-18 16:41:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 818,024 KB
最終ジャッジ日時 2024-04-16 04:11:26
合計ジャッジ時間 4,586 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
using namespace std;
struct dta{
    int p,c;
};
bool lck[10001];
int main(){
    int n;cin>>n;
    queue<dta> nya;
    nya.push({1,0});
    while(nya.size()){
        dta c = nya.front();nya.pop();
        if(c.p==n){
            cout << c.c << endl;
            return 0;
        }
        
        if(0 <= c.p-__builtin_popcount(c.p) && !lck[c.p-__builtin_popcount(c.p)]){
            nya.push({c.p-__builtin_popcount(c.p),c.c+1});
        }
        if(c.p+__builtin_popcount(c.p) <= n && !lck[c.p+__builtin_popcount(c.p)]){
            nya.push({c.p+__builtin_popcount(c.p),c.c+1});
        }
    }
}
0