#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int ch_top=5e7+3;
char ch[ch_top],*now_r=ch-1,*now_w=ch-1;
inline int read(){
register int f=1;
while(*now_r<'0'){
if (*now_r=='-') f=-1;
++now_r;
};
register int x=*now_r-'0';
while(*++now_r>='0')x=x*10+*now_r-'0';
return x*f;
}
const int N=1000010,K=30,MX=(1<<K)-1;
int sum0[N<<2],sum1[N<<2],setv[N<<2],val[N],n;
void create(int o,int l,int r){
sum0[o]=1,setv[o]=-1;
if (l==r) return;
int mid=(l+r)>>1;
create(o<<1,l,mid);
create(o<<1|1,mid+1,r);
}
inline void pushup(int o){
sum0[o]=sum0[o<<1]&sum0[o<<1|1];
sum1[o]=sum1[o<<1]&sum1[o<<1|1];
}
inline void pushdown(int o,int l,int r){
if (~setv[o]){
setv[o<<1]=setv[o<<1|1]=setv[o];
sum0[o<<1]=sum0[o<<1|1]=setv[o]^1;
sum1[o<<1]=sum1[o<<1|1]=setv[o]&1;
int mid=(l+r)>>1;
if (l==mid) val[l]=setv[o]?MX:0;
if (mid+1==r) val[r]=setv[o]?MX:0;
setv[o]=-1;
}
}
void access(int o,int l,int r,int x){
if (l==r) return;
pushdown(o,l,r);
int mid=(l+r)>>1;
if (x<=mid) return access(o<<1,l,mid,x);
else return access(o<<1|1,mid+1,r,x);
}
void qset(int o,int l,int r,int x,int y,int v){
if (x<=l&&r<=y){
setv[o]=v;
sum0[o]=v^1,sum1[o]=v&1;
if (l==r) val[l]=v?MX:0;
return;
}
pushdown(o,l,r);
int mid=(l+r)>>1;
if (y<=mid) qset(o<<1,l,mid,x,y,v);
else if (x>mid) qset(o<<1|1,mid+1,r,x,y,v);
else qset(o<<1,l,mid,x,mid,v),qset(o<<1|1,mid+1,r,mid+1,y,v);
pushup(o);
}
void qchange(int o,int l,int r,int x){
if (l==r){
sum0[o]=val[x]==0;
sum1[o]=val[x]==MX;
return;
}
pushdown(o,l,r);
int mid=(l+r)>>1;
if (x<=mid) qchange(o<<1,l,mid,x);
else qchange(o<<1|1,mid+1,r,x);
pushup(o);
}
int get0(int o,int l,int r,int x){
if (sum0[o]) return -1;
if (l==r) return l+sum0[o];
pushdown(o,l,r);
int mid=(l+r)>>1;
if (x<mid){
int t=get0(o<<1,l,mid,x);
return (~t)?t:get0(o<<1|1,mid+1,r,x);
}
else return get0(o<<1|1,mid+1,r,x);
}
int get1(int o,int l,int r,int x){
if (sum1[o]) return -1;
if (l==r) return l+sum1[o];
pushdown(o,l,r);
int mid=(l+r)>>1;
if (x<mid){
int t=get1(o<<1,l,mid,x);
return (~t)?t:get1(o<<1|1,mid+1,r,x);
}
else return get1(o<<1|1,mid+1,r,x);
}
void qadd(int x,int v){
if (!v||x>n) return;
access(1,1,n,x);
val[x]+=v;
int type=val[x]>MX;
val[x]&=MX;
qchange(1,1,n,x);
if (type){
int to=get1(1,1,n,x);
if (to<=n){
access(1,1,n,to);
++val[to],qchange(1,1,n,to);
if (to>x+1) qset(1,1,n,x+1,to-1,0);
}
}
}
void qminu(int x,int v){
if (!v||x>n) return;
access(1,1,n,x);
val[x]-=v;
int type=val[x]<0;
if (type) val[x]+=MX+1;
qchange(1,1,n,x);
if (type){
int to=get0(1,1,n,x);
if (to<=n){
access(1,1,n,to);
--val[to],qchange(1,1,n,to);
if (to>x+1) qset(1,1,n,x+1,to-1,1);
}
}
}
int main(){
fread(ch,1,ch_top,stdin);
n=read()+1,read(),read(),read();
create(1,1,n);
for (int i=2;i<=n;++i){
int opt=read();
if (opt==1){
int a=read(),b=read();
int id=b/K+1,id2=b%K;
unsigned int v=a<0?-a:a;
v=(v<<id2)&MX;
if (a>=0) qadd(id,v);
else qminu(id,v);
v=a<0?-a:a,v=(v>>(K-id2))&MX;
if (a>=0) qadd(id+1,v);
else qminu(id+1,v);
}
else{
int b=read();
int id=b/K+1,id2=b%K;
access(1,1,n,id);
int v=(val[id]>>id2)&1;
*++now_w=v+'0';
*++now_w='\n';
}
}
fwrite(ch,1,now_w-ch,stdout);
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 8.16 us | 36 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 20.1 us | 36 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 231.18 us | 96 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 359.95 us | 144 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 1.911 ms | 264 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 1.183 ms | 252 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 4.203 ms | 592 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 3.285 ms | 456 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 15.639 ms | 1 MB + 384 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 30.772 ms | 2 MB + 564 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 28.117 ms | 1 MB + 976 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 17.653 ms | 2 MB + 496 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 41.215 ms | 4 MB + 444 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 130.494 ms | 10 MB + 84 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 98.494 ms | 16 MB + 664 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 284.397 ms | 20 MB + 380 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 293.182 ms | 15 MB + 992 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 446.135 ms | 36 MB + 636 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 525.467 ms | 38 MB + 756 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 249 ms | 36 MB + 664 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 346.395 ms | 38 MB + 176 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 570.845 ms | 31 MB + 308 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 753.629 ms | 44 MB + 600 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 614.759 ms | 32 MB + 264 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 776.823 ms | 45 MB + 108 KB | Accepted | Score: 4 | 显示更多 |