// luogu-judger-enable-o2
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=1000010, inf=(1<<30)-1;
struct sgt{int tag, sum, st[2];}tree[maxn<<2];
int n, ans, mx, x, ty, a, b;
char buf[80000010],*ptr=buf-1;
template<typename T>
inline void read(T &k)
{
char c=*++ptr; int f=1; k=0;
while(c<'0' || c>'9') c=='-'&&(f=-1), c=*++ptr;
while(c<='9' && c>='0') k=k*10+c-'0', c=*++ptr;
k*=f;
}
inline void changeone(int x, int delta)
{
tree[x].sum=tree[x].tag=delta;
tree[x].st[0]=(tree[x].sum==0);
tree[x].st[1]=(tree[x].sum==inf);
}
inline void addone(int x, int delta)
{
tree[x].sum+=delta;
tree[x].st[0]=(tree[x].sum==0);
tree[x].st[1]=(tree[x].sum==inf);
}
inline void up(int x)
{
tree[x].st[0]=tree[x<<1].st[0]&tree[x<<1|1].st[0];
tree[x].st[1]=tree[x<<1].st[1]&tree[x<<1|1].st[1];
}
inline void down(int x)
{
if(tree[x].tag!=-1)
{
changeone(x<<1, tree[x].tag);
changeone(x<<1|1, tree[x].tag);
tree[x].tag=-1;
}
}
void change(int x, int l, int r, int cl, int cr, int delta)
{
if(cl<=l && r<=cr){changeone(x, delta); return;}
int mid=(l+r)>>1; down(x);
if(cl<=mid) change(x<<1, l, mid, cl, cr, delta);
if(cr>mid) change(x<<1|1, mid+1, r, cl, cr, delta);
up(x);
}
void update(int x, int l, int r, int cx, int delta)
{
if(l==r){addone(x, delta); return;}
int mid=(l+r)>>1; down(x);
if(cx<=mid) update(x<<1, l, mid, cx, delta);
else update(x<<1|1, mid+1, r, cx, delta);
up(x);
}
int query(int x, int l, int r, int cx)
{
if(l==r) return tree[x].sum;
int mid=(l+r)>>1; down(x);
if(cx<=mid) return query(x<<1, l, mid, cx);
else return query(x<<1|1, mid+1, r, cx);
}
int queryr(int x, int l, int r, int cx, int k)
{
if(l==r) return ans=tree[x].st[k^1], l;
int mid=(l+r)>>1; down(x);
if(cx>mid) return queryr(x<<1|1, mid+1, r, cx, k);
else
{
int pos=queryr(x<<1, l, mid, cx, k);
if(!ans) return pos;
if(tree[x<<1|1].st[k^1]) return r;
return queryr(x<<1|1, mid+1, r, cx, k);
}
}
inline void add(int pos, int delta)
{
int x=query(1, 1, mx, pos);
if(x+delta<=inf) update(1, 1, mx, pos, delta);
else
{
update(1, 1, mx, pos, delta-inf-1);
ans=0; int nxt=queryr(1, 1, mx, pos+1, 0);
update(1, 1, mx, nxt, 1);
if(nxt!=pos+1) change(1, 1, mx, pos+1, nxt-1, 0);
}
}
inline void del(int pos, int delta)
{
int x=query(1, 1, mx, pos);
if(x-delta>=0) update(1, 1, mx, pos, -delta);
else
{
update(1, 1, mx, pos, inf+1-delta);
ans=0; int nxt=queryr(1, 1, mx, pos+1, 1);
update(1, 1, mx, nxt, -1);
if(nxt!=pos+1) change(1, 1, mx, pos+1, nxt-1, inf);
}
}
void build(int x, int l, int r)
{
tree[x].st[0]=1; tree[x].tag=-1;
if(l==r) return;
int mid=(l+r)>>1;
build(x<<1, l, mid); build(x<<1|1, mid+1, r);
}
int main()
{
fread(buf, 1,sizeof(buf), stdin);
read(n); read(x); read(x); read(x); mx=n+233;
build(1, 1, mx);
for(int i=1;i<=n;i++)
{
read(ty);
if(ty==1)
{
read(a); read(b); int p=b/30;
if(a>0)
{
add(p+1, (1ll*a<<(b-p*30))&inf);
add(p+2, a>>(30-(b-p*30)));
}
else
{
a=-a;
del(p+1, (1ll*a<<(b-p*30))&inf);
del(p+2, a>>(30-(b-p*30)));
}
}
else read(x), printf("%d\n", (query(1, 1, mx, x/30+1)>>(x%30))&1);
}
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 40.48 us | 52 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 80.75 us | 60 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 523.02 us | 192 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 1.045 ms | 328 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 2.816 ms | 380 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 2.724 ms | 528 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 6.48 ms | 696 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 5.073 ms | 696 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 24.055 ms | 1 MB + 532 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 45.62 ms | 2 MB + 888 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 33.839 ms | 2 MB + 936 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 39.918 ms | 2 MB + 764 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 64.943 ms | 5 MB + 180 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 216.128 ms | 11 MB + 332 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 224.282 ms | 19 MB + 520 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 466.723 ms | 22 MB + 876 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 361.868 ms | 23 MB + 768 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 755.25 ms | 42 MB + 348 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 908.879 ms | 44 MB + 80 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 395.506 ms | 41 MB + 620 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 760.694 ms | 42 MB + 764 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 740.479 ms | 46 MB + 912 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 1.28 s | 48 MB + 956 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 794.488 ms | 47 MB + 860 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 1.273 s | 49 MB + 312 KB | Accepted | Score: 4 | 显示更多 |