上次打cf用到了线性基,可惜没有板子,现场写了一个封装好的线性基,思来思去还是存个板子吧
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <bits/stdc++.h>
#define x first
#define y second
#define int long long
using namespace std ;
int read(){
int res = 0 , flag = 1 ;
char c = getchar() ;
while(!isdigit(c)){
if(c == '-') flag = -1 ;
c = getchar() ;
}
while(isdigit(c)){
res = (res << 1) + (res << 3) + (c ^ 48) ;
c = getchar() ;
}
return res * flag ;
}
void write(int x){
if(x < 0) {
putchar('-') ;
x = - x ;
}
if(x >= 10) write(x / 10) ;
putchar('0' + x % 10) ;
}
void write(int x , char c){
write(x) ;
putchar(c) ;
}
const int N = 2e5 + 10 ;
typedef pair<int , int> pii ;
typedef pair<double ,double> pdd ;
const int mod = 998244353 ;
const int inf = 1e9 + 10 ;
const int M = 2 * N ;
const int K = 32 ;
struct M{
int a[K] = {
} ;
M(){
for(int i = 0 ; i < K ; i ++) a[i] = 0 ;
}
void insert(int x){
for(int i = K - 1 ; i >= 0 ; i --){
if((x >> i) & 1) {
if(!a[i]){
a[i] = x ;
return ;
}
else
x ^= a[i] ;
}
}
}
M operator+(M& t){
M c ;
for(int i = 0 ; i < K ; i ++) c.a[i] = a[i] ;
for(int i = 0 ; i < K ; i ++)
if(t.a[i]) c.insert(t.a[i]) ;
return c ;
}
void equal(M& t){
for(int i = 0 ; i < K ; i ++) a[i] = t.a[i] ;
}
void clear(){
for(int i = 0 ; i < K ; i ++) a[i] = 0 ;
}
int get(){
int res = 0 ;
for(int i = K - 1 ; i >= 0 ; i --)
if((res ^ a[i]) > res) res ^= a[i] ;
return res ;
}
} ;
void solve() {
}
signed main(void){
solve() ;
}