【板子】线性基(待填)

//lg p3812
#include<bits/stdc++.h>
using namespace std;

#define ll unsigned long long

ll d[100];
int n;

void Insert(ll x)
{
	for(int i=62;i>=1;i--)
	{
		if(!(x>>(i-1))) continue;
		if(!d[i])
		{
			d[i]=x;
			return ;
		}
		else 
		{
			x^=d[i];
		}
	}
}

ll FindMax()
{
	ll ans=d[62];
	for(int i=62;i>=1;i--)
	{
		if((ans^d[i])>ans)
		{
			ans^=d[i];
		}
	}
	return ans;
}

int main()
{
	// freopen("working.in","r",stdin);
	// freopen("working.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		ll x;
		cin>>x;
		Insert(x);
	}
	cout<<FindMax();
	return 0;
}
posted @ 2024-01-26 20:58  yeyou26  阅读(8)  评论(0编辑  收藏  举报