#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 500010, S = 60;
ll a, b, INF = (1LL << S) - 1, f[maxn];
int n, m, t1, t2, t3;
struct segment_tree {
int l, r, pos;
ll lazy;
bool all[2];
} tree[maxn << 2];
void maintain(int k) {
tree[k].all[0] = tree[k << 1].all[0] & tree[k << 1 | 1].all[0];
tree[k].all[1] = tree[k << 1].all[1] & tree[k << 1 | 1].all[1];
}
void modify(int k, ll x) {
if (tree[k].pos != -1) f[tree[k].pos] = x; tree[k].lazy = x;
if (x == 0) tree[k].all[0] = 1, tree[k].all[1] = 0;
else if (x == INF) tree[k].all[0] = 0, tree[k].all[1] = 1;
else tree[k].all[0] = tree[k].all[1] = 0;
}
void pushdown(int k) {
if (tree[k].lazy == -1) return;
modify(k << 1, tree[k].lazy), modify(k << 1 | 1, tree[k].lazy);
tree[k].lazy = -1;
}
void build(int k, int l, int r) {
tree[k].l = l, tree[k].r = r, tree[k].all[0] = 1, tree[k].lazy = tree[k].pos = -1;
if (l == r) { tree[k].pos = l; return; }
int mid = (l + r) >> 1;
build(k << 1, l, mid), build(k << 1 | 1, mid + 1, r);
}
void change(int k, int l, int r, ll x) {
if (tree[k].l == l && tree[k].r == r) { modify(k, x); return; }
pushdown(k);
int mid = (tree[k].l + tree[k].r) >> 1;
if (mid >= r) {
change(k << 1, l, r, x);
} else if (mid < l) {
change(k << 1 | 1, l, r, x);
} else {
change(k << 1, l, mid, x), change(k << 1 | 1, mid + 1, r, x);
}
maintain(k);
}
int find_nxt(int k, int p, int v) {
if (tree[k].all[!v]) return -1;
if (tree[k].l == tree[k].r) return tree[k].l;
int mid = (tree[k].l + tree[k].r) >> 1, t;
if (mid >= p && (t = find_nxt(k << 1, p, v)) != -1) return t;
return find_nxt(k << 1 | 1, p, v);
}
ll query(int k, int p) {
if (tree[k].l == tree[k].r) return f[tree[k].l];
pushdown(k);
int mid = (tree[k].l + tree[k].r) >> 1;
if (mid >= p) {
return query(k << 1, p);
} else {
return query(k << 1 | 1, p);
}
}
void add(int p, ll x) {
ll t = query(1, p); change(1, p, p, (t + x) & INF);
if (t + x > INF) {
t = find_nxt(1, p + 1, 0);
change(1, t, t, f[t] + 1);
if (p + 1 < t) change(1, p + 1, t - 1, 0);
}
}
void sub(int p, ll x) {
ll t = query(1, p); change(1, p, p, (t - x) & INF);
if (t - x < 0) {
t = find_nxt(1, p + 1, 1);
change(1, t, t, f[t] - 1);
if (p + 1 < t) change(1, p + 1, t - 1, INF);
}
}
int main() {
scanf("%d %d %d %d", &m, &t1, &t2, &t3), n = (m + 2) >> 1;
build(1, 0, n);
for (int i = 1, op; i <= m; i++) {
scanf("%d %lld", &op, &a);
if (op == 1) {
scanf("%lld", &b);
if (a > 0) {
int p = b / S, r = b % S;
ll x = a << r & INF;
if (x) add(p, x);
p++, a >>= (S - r);
if (b) add(p, a);
} else {
a = -a;
int p = b / S, r = b % S;
ll x = a << r & INF;
if (x) sub(p, x);
p++, a >>= (S - r);
if (b) sub(p, a);
}
} else {
printf("%d\n", query(1, a / S) >> (a % S) & 1);
}
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 39.66 us | 44 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 73.98 us | 48 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 714.56 us | 108 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 1.411 ms | 172 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 3.263 ms | 300 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 3.09 ms | 304 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 6.167 ms | 596 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 5.524 ms | 560 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 22.405 ms | 1 MB + 176 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 41.158 ms | 2 MB + 264 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 40.915 ms | 2 MB + 88 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 39.425 ms | 2 MB + 336 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 57.939 ms | 4 MB + 356 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 188.937 ms | 8 MB + 940 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 225.482 ms | 17 MB + 368 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 412.321 ms | 17 MB + 820 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 431.337 ms | 16 MB + 404 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 653.274 ms | 34 MB + 696 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 785.199 ms | 35 MB + 124 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 763.007 ms | 35 MB + 876 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 789.607 ms | 36 MB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 839.296 ms | 32 MB + 716 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 1.083 s | 36 MB + 168 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 905.36 ms | 32 MB + 760 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 1.154 s | 36 MB + 444 KB | Accepted | Score: 4 | 显示更多 |