第一次学pb_ds,本地Re交上去WA了
查看原帖
第一次学pb_ds,本地Re交上去WA了
759274
Stevehim楼主2023/4/20 21:01

rt

#include <bits/stdc++.h>
#include <bits/extc++.h>
#define maxn 100010
//using namespace std;
using namespace __gnu_pbds;
tree<int, null_type,std::less<int>, rb_tree_tag,tree_order_statistics_node_update> t;
int n;
int opt,x;

int main(){
	std::cin >> n;
	for(int i = 1; i <= n; i++){
		std::cin >> opt >> x;
		if(opt == 1) t.insert(x);
		else if(opt == 2) t.erase(x);
		else if(opt == 3) std::cout << t.order_of_key(x) << std::endl;
		else if(opt == 4) std::cout << *t.find_by_order(x) << std::endl;
		else if(opt == 5) std::cout << *t.lower_bound(x) << std::endl;
		else std::cout << *t.upper_bound(x) << std::endl;
	}
	return 0;
}

验证码rp pb(_ds)祭

2023/4/20 21:01
加载中...