P4869 albus就是要第一个出场

题目

查询一个数在不去重集合异或和中的排名。

分析

直接贴题解了。

代码

#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x){
	x=0;char ch=getchar();bool f=false;
	while(!isdigit(ch)){if(ch=='-'){f=true;}ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=f?-x:x;
	return ;
}
template <typename T>
inline void write(T x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10^48);
	return ;
}
#define ll long long
#define ull unsigned long long
#define inc(x,y,mod) (((x)+(y))>=(mod)?(x)+(y)-(mod):(x)+(y))
#define dec(x,y,mod) ((x)-(y)<0?(x)-(y)+(mod):(x)-(y))
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
#define dep(i,y,x) for(int i=(y);i>=(x);i--)
const int N=1e5+5,NM=62,M=2e5+5,MOD=10086;
int n;
ll m,cnt=1;
struct node{
	ll x,y;
	inline bool operator < (const node &B)const{return y>B.y;}
}a[N];
ll d[N];
ll sum;
inline void Insert(ll x){
	for(int i=NM;~i;i--){
		if(x&(1ll<<i)){
			if(d[i]) x^=d[i];
			else{d[i]=x;return ;}
		}
	}
	cnt=cnt*2%MOD;
	return ;
}
signed main(){
	ios::sync_with_stdio(false);
	read(n);
	for(int i=1,x;i<=n;i++) read(x),Insert(x);
	read(m);ll tmp=1;
	for(int i=0;i<=NM;i++){
		if(d[i]){
			if(m&(1ll<<i)) sum+=tmp;
			tmp<<=1;
		}
	}
	write(sum*cnt%MOD+1);
	return 0;
}


posted @ 2021-08-05 19:50  __Anchor  阅读(71)  评论(0)    收藏  举报