結果

問題 No.184 たのしい排他的論理和(HARD)
コンテスト
ユーザー YS55749378
提出日時 2022-03-30 13:22:52
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 1,336 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,469 ms
コンパイル使用メモリ 193,876 KB
実行使用メモリ 48,512 KB
最終ジャッジ日時 2026-05-10 01:09:40
合計ジャッジ時間 8,437 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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