結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー dyktr_06dyktr_06
提出日時 2022-12-25 05:01:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 1,594 bytes
コンパイル時間 2,371 ms
コンパイル使用メモリ 205,956 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 18:47:42
合計ジャッジ時間 7,375 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 51 ms
4,380 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 38 ms
4,380 KB
testcase_11 AC 28 ms
4,380 KB
testcase_12 AC 57 ms
4,376 KB
testcase_13 AC 62 ms
4,380 KB
testcase_14 AC 36 ms
4,376 KB
testcase_15 AC 67 ms
4,384 KB
testcase_16 AC 56 ms
4,376 KB
testcase_17 AC 61 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 16 ms
4,376 KB
testcase_21 AC 71 ms
4,380 KB
testcase_22 AC 71 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 41 ms
4,380 KB
testcase_29 AC 59 ms
4,376 KB
testcase_30 AC 53 ms
4,384 KB
testcase_31 AC 47 ms
4,380 KB
testcase_32 AC 58 ms
4,380 KB
testcase_33 AC 69 ms
4,380 KB
testcase_34 AC 67 ms
4,376 KB
testcase_35 AC 70 ms
4,384 KB
testcase_36 AC 70 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define PROBLEM "https://yukicoder.me/problems/no/184"
#include <bits/stdc++.h>
using namespace std;

template <typename T>
struct BinaryBasis{

    vector<T> basis, original;
    BinaryBasis(const vector<T>& vec){
        for(auto x : vec){
            T y = x;
            for(auto z : basis){
                y = min(y, y ^ z);
            }
            if(y > 0){
                basis.push_back(y);
                original.push_back(x);
            }
        }
        normalize();
    }

    void add(const T &x){
        T y = x;
        for(auto z : basis){
            y = min(y, y ^ z);
        }
        if(y > 0){
            basis.push_back(y);
            original.push_back(x);
        }
    }

    void normalize(){
        sort(basis.begin(), basis.end());
        for(int i = 0; i < (int) basis.size(); ++i){
            for(int j = 0; j < i; ++j){
                basis[i] = min(basis[i], basis[i] ^ basis[j]);
            }
        }
    }

    bool exist(const T &x){
        T y = x;
        for(auto z : basis){
            y = min(y, y ^ z);
        }
        return y > 0;
    }

    T kth_element(const long long &k){
        T res = 0;
        for(int i = 0; i < (int) basis.size(); ++i){
            if(k & (1LL << i)){
                res ^= basis[i];
            }
        }
        return res;
    }

    size_t size(){
        return basis.size();
    }
};

int main(){
    int n; cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    BinaryBasis<long long> basis(a);
    cout << (1LL << (basis.size())) << "\n";
}
0