// integer naive_new.cpp[nm/1024] by wys @2017-06-27
#include <stdio.h>
#include <stdint.h>
const int MAXN = 1000005;
const int MAXM = MAXN * 30 + 100;
const int MAXLEN = MAXM / 32 + 1;
const int MAXLEN2 = MAXLEN / 32 + 1;
uint32_t A[MAXLEN];
uint32_t is_0[MAXLEN2];
uint32_t is_1[MAXLEN2];
void get(int pos) {
if (is_0[pos >> 5] & (1u << (pos & 31))) {
A[pos] = 0;
}
if (is_1[pos >> 5] & (1u << (pos & 31))) {
A[pos] = -1;
}
}
void update(int pos) {
uint32_t tmp = A[pos];
if (tmp == 0) {
is_0[pos >> 5] |= 1u << (pos & 31);
} else {
is_0[pos >> 5] &= ~(1u << (pos & 31));
}
if (tmp == -1) {
is_1[pos >> 5] |= 1u << (pos & 31);
} else {
is_1[pos >> 5] &= ~(1u << (pos & 31));
}
}
void _add1(int p) {
for (; p & 31; p++) {
get(p), ++A[p], update(p);
if (A[p] != 0) return;
}
int q = p >> 5;
while (is_1[q] == -1) {
is_0[q] = -1;
is_1[q] = 0;
++q;
}
p = q << 5;
for (; ; p++) {
get(p), ++A[p], update(p);
if (A[p] != 0) return;
}
}
void _sub1(int p) {
for (; p & 31; p++) {
get(p), --A[p], update(p);
if (A[p] != -1) return;
}
int q = p >> 5;
while (is_0[q] == -1) {
is_1[q] = -1;
is_0[q] = 0;
++q;
}
p = q << 5;
for (; ; p++) {
get(p), --A[p], update(p);
if (A[p] != -1) return;
}
}
void _add(int pos, uint32_t val) {
get(pos);
if ((A[pos] += val) < val) {
_add1(pos + 1);
}
update(pos);
}
void _sub(int pos, uint32_t val) {
get(pos);
if (A[pos] < val) {
_sub1(pos + 1);
}
A[pos] -= val;
update(pos);
}
void add(int _a, int b) {
if (_a == 0) return;
bool neg = _a < 0;
uint32_t a = neg ? -_a : _a;
// b/32, b%32, 32-b%32, b/32+1, 0, b%32
int pos = b >> 5;
int off = b & 31;
int len1 = 32 - off;
// log(1e9) = 30
uint32_t part1 = len1 >= 30 ? a : (a & ((1u << len1) - 1));
uint32_t part2 = len1 >= 30 ? 0 : (a >> len1);
if (part1) (neg ? _sub : _add)(pos, part1 << off);
if (part2) (neg ? _sub : _add)(pos + 1, part2);
}
int query(int k) {
return get(k >> 5), ((A[k >> 5]) >> (k & 31)) & 1u;
}
int main() {
#ifndef WYS
freopen("integer.in", "r", stdin);
freopen("integer.out", "w", stdout);
#endif
int n, t1, t2, t3;
scanf("%d%d%d%d", &n, &t1, &t2, &t3);
for (int i = 0; i < MAXLEN2; i++) {
is_0[i] = -1;
}
for (int i = 0; i < n; i++) {
int op, a, b, k;
scanf("%d", &op);
if (op == 1) {
scanf("%d%d", &a, &b);
add(a, b);
} else {
scanf("%d", &k);
putchar("01"[query(k)]);
putchar('\n');
}
}
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 25.57 us | 140 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #2 | 39.06 us | 140 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #3 | 271.35 us | 140 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #4 | 415.56 us | 140 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #5 | 995.25 us | 140 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #6 | 1.065 ms | 144 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #7 | 2.27 ms | 176 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #8 | 1.681 ms | 144 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #9 | 12.556 ms | 268 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #10 | 31.291 ms | 352 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #11 | 11.782 ms | 184 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #12 | 22.48 ms | 420 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #13 | 45.237 ms | 444 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #14 | 407.877 ms | 1008 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #15 | 461.39 ms | 1 MB + 424 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #16 | 1.57 s | 1 MB + 860 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #17 | 157.899 ms | 496 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #18 | 2 s | 2 MB + 500 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #19 | 2 s | 2 MB + 880 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #20 | 90.883 ms | 3 MB + 868 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #21 | 2 s | 3 MB + 668 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #22 | 381.296 ms | 808 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #23 | 2 s | 956 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #24 | 394.517 ms | 852 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #25 | 2 s | 3 MB + 980 KB | Time Limit Exceeded | Score: 0 | 显示更多 |