pbds20分求调
查看原帖
pbds20分求调
406941
Register_int-std=c++14楼主2022/8/9 17:35
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> t;

int last, ans;

int n, m, opt;

ll x;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) scanf("%lld", &x), t.insert(x << 20 | i);
	for (int i = n; i < n + m; i++) {
		scanf("%d%lld", &opt, &x);
		x ^= last;
		switch (opt) {
		case 1: t.insert(x << 20 | i); break;
		case 2: t.erase(t.lower_bound(x << 20)); break;
		case 3: last = t.order_of_key(x << 20) + 1; break;
		case 4: last = *t.find_by_order(x - 1) >> 20; break;
		case 5: last = *--t.lower_bound(x << 20) >> 20; break;
		case 6: last = *t.upper_bound(x << 20 | n + m) >> 20; break;
		}
		if (opt >= 3) ans ^= last;
	}
	printf("%d\n", ans);
}
2022/8/9 17:35
加载中...