結果

問題 No.2538 2進元ゲーム
ユーザー momoyuu
提出日時 2023-11-10 22:21:56
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,036 bytes
コンパイル時間 3,139 ms
コンパイル使用メモリ 262,804 KB
実行使用メモリ 20,480 KB
最終ジャッジ日時 2024-09-26 01:47:22
合計ジャッジ時間 8,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35 WA * 1 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

map<__int128_t,ll> memo,vis;
int n;
ll calc(__int128_t ni){
    if(vis[ni]) return memo[ni];
    vector<int> use;
    for(int i = 0;i<=100;i++){
        if(ni>>i&1) use.push_back(calc(i));
    }
    if(ni<0){
        for(int i = 100;i<=400;i++) use.push_back(calc(i));
    }
    sort(use.begin(),use.end());
    int now = 0;
    for(int i = 0;i<use.size();i++){
        if(now==use[i]) now++;
        if(now<use[i]) break;
    }
    vis[ni]++;
    return memo[ni] = now;
}

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i = 0;i<n;i++) cin>>a[i];
    ll now = 0;
    for(int i = 0;i<n;i++) now ^= calc(a[i]);
    auto b = a;
    sort(b.begin(),b.end());
    bool no = false;
    for(int i = 0;i+1<b.size();i+=2){
        if(b[i]==b[i+1])continue;
        no = true;
    }
    if(n%2==1) no = true;
    for(int i = 0;i<n;i++) if(a[i]<0&&(!no)){
        cout<<1<<endl;
        return 0;
    }
    if(now==0) cout<<2<<endl;
    else cout<<1<<endl;
}
0