結果

問題 No.2538 2進元ゲーム
ユーザー milanis48663220milanis48663220
提出日時 2023-11-10 22:51:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,226 bytes
コンパイル時間 1,296 ms
コンパイル使用メモリ 122,304 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-10 22:51:27
合計ジャッジ時間 3,173 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

int grundy[61];

int mex(vector<int> v){
    int n = v.size();
    vector<bool> used(n);
    for(int x: v){
        if(x < n) used[x] = true;
    }
    for(int i = 0; i < n; i++){
        if(!used[i]) return i;
    }
    return n;
}

void init(){
    for(int x = 1; x <= 60; x++){
        vector<int> v;
        for(int i = 0; i < 20; i++){
            if(x&(1<<i)){
                v.push_back(grundy[i]);
            }
        }
        grundy[x] = mex(v);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    int n; cin >> n;
    int x = 0;
    for(int i = 0; i < n; i++){
        ll a; cin >> a;
        vector<int> v;
        if(a < 0 && abs(a) <= 60){
            a = (1ll<<(abs(a)))+a;
        }
        for(int i = 0; i <= 60; i++){
            ll p = 1ll<<i;
            if((a&p) == p){
                v.push_back(grundy[i]);
            }
        }
        x ^= mex(v);
    }
    if(x == 0){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }

}
0