結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー YS55749378YS55749378
提出日時 2022-03-30 13:22:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,336 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 177,124 KB
実行使用メモリ 69,504 KB
最終ジャッジ日時 2024-11-14 13:36:16
合計ジャッジ時間 125,517 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 TLE * 20
権限があれば一括ダウンロードができます

ソースコード

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