template
Daniope1266 · · 个人记录
#define Tree tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update>
Tree t;
int n,a[_],ct,m;
int ans,L;
signed main(){
ios::sync_with_stdio(0),cin.tie(0);
cin>>n>>m;
FOR(n)cin>>a[i],ct++,t.insert({a[i],ct});
while(m--){
int o,x;
cin>>o>>x;
x^=L;
if(o==1)ct++,t.insert({x,ct});
if(o==2){
auto p=t.lower_bound({x,-INF});
if(p->first!=x){sc<<"noexist\n";exit(0);}
t.erase(p);
}
if(o==3){
L=t.order_of_key({x,-INF})+1;
ans^=L;
}
if(o==4){
L=t.find_by_order(x-1)->first;
ans^=L;
}
if(o==5){
auto p=t.lower_bound({x,-INF});
p--;
L=p->first;
ans^=L;
}
if(o==6){
auto p=t.lower_bound({x,INF});
L=p->first;
ans^=L;
}
}
cout<<ans<<endl;
}