【模板】线性基

造板子
普通的高斯消元

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,t1,t2,t3,t4;

// Linear Base to Get Max xor sum
// Method: insert(x) solve()
struct linear_base {
    int a[64];
    void insert(int k) {
        for(int j=63; j>=0; --j)
            if((k>>j)&1ll)
                if(a[j]==0) {a[j]=k;break;}
                else k^=a[j];
    }
    int solve() {
        int ans = 0;
        for(int i=59; i>=0; --i)
            if((ans^a[i]) > ans) ans^=a[i];
        return ans;
    }
} l;

signed  main() {
    cin>>n;
    for(int i=1; i<=n; i++) {
        int k;
        cin>>k;
        l.insert(k);
    }
    cout<<l.solve();
}

原文地址:https://www.cnblogs.com/mollnn/p/12348749.html