結果

問題 No.3 ビットすごろく
コンテスト
ユーザー mnm
提出日時 2022-06-04 15:42:59
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 655 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 708 ms
コンパイル使用メモリ 92,216 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-09 11:22:57
合計ジャッジ時間 2,162 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>

#define rep(i,n) for(i=0; i<n; ++i)
#define in(a) cin >> a
#define out(a,b) cout << a << b
using namespace std;
using lint = long long;

int main(void){
    int i, j, n, m, k, cnt = 1;
    in(n);
    bitset<9999> masu(0);
    int cur = 0;
    
    while(cur>=0&&!masu[cur]){
        masu.set(cur);
        if(cur==n-1)    break;
        bitset<14> bit(cur+1);
        int forw = bit.count();
        if(n-1<cur+forw)    cur-=forw;
        else    cur+=forw;
        cnt++;
    }
    masu[n-1] ? out(cnt,endl) : out(-1,endl);
    return 0;
}

0