pb_ds 65分
查看原帖
pb_ds 65分
744989
kunkunge楼主2024/6/2 11:39
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
using namespace std;
__gnu_pbds::tree<int, __gnu_pbds::null_type,
                 std::less<int>, __gnu_pbds::rb_tree_tag,
                 __gnu_pbds::tree_order_statistics_node_update>
    sb;
int main(){
	int n;cin >> n;
	while(n--){
		int op,x;cin >> op >> x;
		if(op==1){
			sb.insert(x);
		}else if(op==2){
			sb.erase(x);
		}else if(op==3){
			cout << sb.order_of_key(x)+1 << "\n";
		}else if(op==4){
			cout << *(sb.find_by_order(x-1)) << "\n";
		}else if(op==5){
			cout << *(--sb.lower_bound(x)) << "\n";
		}else if(op==6){
			cout << *(sb.upper_bound(x)) << "\n";
		}
	}
	return 0;
}
2024/6/2 11:39
加载中...