STL tree,pts20,求调
  • 板块题目总版
  • 楼主hanss6
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/4/27 18:01
  • 上次更新2024/4/27 20:24:45
查看原帖
STL tree,pts20,求调
537719
hanss6楼主2024/4/27 18:01

普通平衡树加强版

#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define int long long
tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> T;
int n,m;
int k,ans,a,x;
signed main(){ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>k;
		T.insert((k<<30)+i);
	}
	for(int i=1;i<=m;i++){
		int op;
		cin>>op>>k;
		if(op==1){
			T.insert((k<<30)+i);
		}else if(op==2){
			T.erase(T.lower_bound(k<<30));
		}else if(op==3){
			a=T.order_of_key(k<<30)+1;
		}else if(op==4){
			ans=*T.find_by_order(k-1);
			a=ans>>30;
		}else if(op==5){
			ans=*--T.lower_bound(k<<30);
			a=ans>>30;
		}else{
			ans=*T.upper_bound((k<<30)+n);
			a=ans>>30;
		}
		if(op!=1&&op!=2){
			x^=a;
		}
	}
	cout<<x;
	return 0;
}
2024/4/27 18:01
加载中...