結果

問題 No.2538 2進元ゲーム
ユーザー momoyuumomoyuu
提出日時 2023-11-10 22:19:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,319 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 2,914 ms
コンパイル使用メモリ 259,444 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2023-11-10 22:19:54
合計ジャッジ時間 7,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 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 1 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 AC 2 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 8 ms
6,676 KB
testcase_30 AC 73 ms
6,676 KB
testcase_31 AC 563 ms
13,952 KB
testcase_32 AC 411 ms
13,952 KB
testcase_33 AC 458 ms
13,952 KB
testcase_34 AC 72 ms
6,676 KB
testcase_35 AC 1,319 ms
19,712 KB
testcase_36 AC 74 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

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));
    }
    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]);
    for(int i = 0;i<n;i++) if(a[i]<0&&n>3e3){
    	cout<<1<<endl;
    	return 0;
    }
    if(now==0) cout<<2<<endl;
    else cout<<1<<endl;
}
0