結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー YS55749378YS55749378
提出日時 2022-03-30 13:22:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,336 bytes
コンパイル時間 1,864 ms
コンパイル使用メモリ 175,536 KB
実行使用メモリ 48,932 KB
最終ジャッジ日時 2024-04-26 21:57:54
合計ジャッジ時間 8,900 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 TLE -
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 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
#define REP2(i,m,n) for(long i=(long)m;i<(long)n;++i)
#define REP(i,n) REP2(i,0,n)

void yesno(bool flag){
    cout<<(flag?"Yes":"No")<<endl;
}

// 引数:vector配列の先頭ポインタ,vector本数,bit数 返り値:基底bitのリスト 影響:配列が掃き出し後の状態に
vector<long> binary_xor_elimination(vector<long> A[],long n,long b){
    sort(A,A+n);
    reverse(A,A+n);
    vector<long> res;
    REP(i,n){
        long maxb=0;
        while(maxb<b && A[i][maxb]==0) maxb++;
        if(maxb<b){
            res.push_back(maxb);
            REP2(j,i+1,n){
                if(A[j][maxb]==1){
                    REP(k,b) A[j][k]^=A[i][k];
                }
            }
            sort(A+i+1,A+n);
            reverse(A+i+1,A+n);
        }
    }
    return res;
}

vector<long> base2(long x){
    vector<long> res;
    REP(i,64){
        res.push_back(x%2);
        x/=2;
    }
    return res;
}

int main(){
    long n;
    cin>>n;
    long a[n];
    REP(i,n) cin>>a[i];
    vector<long> v[n];
    REP(i,n) v[i]=base2(a[i]);
    vector<long> bitlist=binary_xor_elimination(v,n,64);
    long l=bitlist.size();
    cout<<(1LL<<l)<<endl;
    return 0;
}
0