結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー dyktr_06dyktr_06
提出日時 2022-12-25 05:01:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 1,594 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 206,956 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 10:11:25
合計ジャッジ時間 6,133 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 54 ms
5,376 KB
testcase_09 AC 13 ms
5,376 KB
testcase_10 AC 41 ms
5,376 KB
testcase_11 AC 30 ms
5,376 KB
testcase_12 AC 63 ms
5,376 KB
testcase_13 AC 67 ms
5,376 KB
testcase_14 AC 40 ms
5,376 KB
testcase_15 AC 72 ms
5,376 KB
testcase_16 AC 61 ms
5,376 KB
testcase_17 AC 66 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 17 ms
5,376 KB
testcase_21 AC 75 ms
5,376 KB
testcase_22 AC 74 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 45 ms
5,376 KB
testcase_29 AC 64 ms
5,376 KB
testcase_30 AC 57 ms
5,376 KB
testcase_31 AC 49 ms
5,376 KB
testcase_32 AC 61 ms
5,376 KB
testcase_33 AC 73 ms
5,376 KB
testcase_34 AC 72 ms
5,376 KB
testcase_35 AC 74 ms
5,376 KB
testcase_36 AC 74 ms
5,376 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