pbds20分求调

P6136 【模板】普通平衡树(数据加强版)

Register_int @ 2022-08-09 17:35:04

#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);
}

by RenaMoe @ 2022-08-09 18:02:25

@Register_int case 4 写错了


by RenaMoe @ 2022-08-09 18:07:00

不对啊,左移 20 位是不是不太够


by Register_int @ 2022-08-09 19:25:16

@RenaMoe 谢大佬


by Register_int @ 2022-08-09 19:26:36


|