代码如下
#include <cstdio>
#include <cctype>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<ll,ll> P;
tree<P,null_type,less<P>,rb_tree_tag,tree_order_statistics_node_update> t;
inline ll read()
{
ll x=0;char ch=getchar();
while(!isdigit(ch))ch=getchar();
while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
return x;
}
int main()
{
//freopen("P6136_2.in","r",stdin);
int n=read(),m=read(),c=1;
ll temp=0,ans=0;
for(int i=1;i<=n;++i)
t.insert({read(),c++});
for(int i=1;i<=m;++i)
{
ll op=read(),x=read();
if(op==1)
t.insert({x^temp,c});
else if(op==2)
t.erase(t.lower_bound({x^temp,0}));
else if(op==3)
{
temp=t.order_of_key({x^temp,0})+1;
ans=ans^temp;
}
else if(op==4)
{
temp=t.find_by_order((x^temp)-1)->first;
ans=ans^temp;
}
else if(op==5)
{
temp=prev(t.lower_bound({x^temp,0}))->first;
ans=ans^temp;
}
else
{
temp=t.lower_bound({(x^temp)+1,0})->first;
ans=ans^temp;
}
}
printf("%llu",ans);
return 0;
}