跳到正文

个人记录

template

Daniope1266约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年11月13日
收录
2026年11月20日
更新
2026年11月22日
篇幅
约 2 分钟

版本

  1. v1当前
C++
#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;
}
原文