codeforces 1100F

传送门:http://codeforces.com/contest/1100/problem/F

题意:n个数,q个询问,每次询问区间异或最大值。

题解:普通的线段树会超时,我们考虑对每位有贡献的数最远是哪里,然后记录下来更新即可。

#include
using namespace std;
int b[500005],ans[500005];
struct Base{
	int a[23],pos[23];
	Base(){for(int i=0;i<23;i++)a[i]=0;}
	void up(int &a,int b){if(b>a)a=b;}
	void ins(int x,int r){
		for(int i=22;~i;i--)
			if(x>>i&1){
				if(a[i]){
					if(pos[i]=r)
				up(t,t^a[i]);
		return t;
	}
}f;
struct node{
	int l,r,idx;
	bool operator <(const node &a)const{
		if(r==a.r)return l

 

你可能感兴趣的:(线性基)