#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
char ibuf[1<<25],*ih=ibuf,obuf[1<<21],*oh=obuf;
inline void read(int&x){
int f=1;
for(x=0;!isdigit(*ih);++ih)if(*ih=='-')f=-1;
for(;isdigit(*ih);x=x*10+*ih++-48);x*=f;
}
const int N=1100005;
const ull all=(1ll<<60)-1;
int n,t1,t2,t3;
ull p[N/2],q[N/2],bi[70];
struct tree{
unsigned short ch[6][N/4];
int low[65539],high[65539],l,hib[65539],pr[65539][16];
inline void ini(int n){
for(l=0;1<<(l*4)<=n;++l);--l;
int i,j;
for(i=0;i<65536;++i){
for(j=0;i>>j&1;++j);low[i]=j;
for(j=15;j>=0 && i>>j&1;--j);high[i]=j;
int lst=0;
for(j=0;j<16;++j){
pr[i][j]=lst;
if(!(i>>j&1))lst=j;
}
}
for(i=0;i<=l;++i)
memset(ch[i],-1,2<<(i*4));
}
inline void ins(int i){
ch[l][i>>4]|=1<<(i&15);i>>=4;
for(int j=l;j && ch[j][i]==65535;--j,i>>=4)
ch[j-1][i>>4]|=1<<(i&15);
}
inline void del(int i){
for(int j=l;j>=0 && ch[j][i>>4]>>(i&15)&1;--j,i>>=4)
ch[j][i>>4]^=1<<(i&15);
}
inline int ask(int i){
if(i<0)return 0;
int j=l;
for(;j>=0;--j,i>>=4){
if(low[ch[j][i>>4]]<(i&15)){
int x=(i>>4<<4)|pr[ch[j][i>>4]][i&15];++j;
for(;j<=l;x=x<<4|high[ch[j][x]],++j);
return x+1;
}
}
return 0;
}
}T;
inline void add(ull x,int y){
for(;x;++y){
if(p[y]==q[y])T.del(y);
p[y]+=x;x=p[y]>>60;p[y]&=all;
if(p[y]==q[y])T.ins(y);
}
}
inline void mns(ull x,int y){
for(;x;++y){
if(p[y]==q[y])T.del(y);
q[y]+=x;x=q[y]>>60;q[y]&=all;
if(p[y]==q[y])T.ins(y);
}
}
int main(){
//freopen("integer5.in","r",stdin);
fread(ibuf,1,1<<25,stdin);
read(n);read(t1);read(t2);read(t3);
T.ini(n+25);
for(int i=0;i<=60;++i)bi[i]=(1ll<<i)-1;
int cnt=0;
while(n--){
int o,a,b;
read(o);read(a);
if(o==1){
read(b);
int x=60-b%60,y=b/60;
if(a<0){
a=-a,mns(((ull)a&bi[x])<<(b%60),y);
mns((ull)a>>x,y+1);
}else add(((ull)a&bi[x])<<(b%60),y),add((ull)a>>x,y+1);
}else{
int x=a%60,y=a/60,z=(p[y]>>x&1)-(q[y]>>x&1);
if((p[y]&bi[x])==(q[y]&bi[x])){
int u=T.ask(y);
if(u && p[u-1]<q[u-1])--z;
}else z-=(p[y]&bi[x])<(q[y]&bi[x]);
*oh++='0'+(z+4)%2;*oh++='\n';
}
}
return fwrite(obuf,1,oh-obuf,stdout),0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 1.157 ms | 4 MB + 580 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 1.162 ms | 4 MB + 580 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 1.216 ms | 4 MB + 612 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 1.235 ms | 4 MB + 624 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 1.333 ms | 4 MB + 688 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 1.336 ms | 4 MB + 676 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 1.51 ms | 4 MB + 812 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 1.452 ms | 4 MB + 752 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 2.39 ms | 5 MB + 316 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 3.107 ms | 5 MB + 528 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 3.102 ms | 5 MB + 520 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 3.378 ms | 5 MB + 840 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 4.269 ms | 6 MB + 432 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 10.716 ms | 9 MB + 656 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 12.727 ms | 10 MB + 664 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 21.146 ms | 14 MB + 828 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 18.91 ms | 12 MB + 860 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 33.609 ms | 19 MB + 960 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 40.944 ms | 22 MB + 512 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 54.732 ms | 18 MB + 96 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 46.961 ms | 22 MB + 828 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 34.433 ms | 20 MB + 344 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 49.527 ms | 23 MB + 360 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 36.57 ms | 21 MB + 348 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 65.414 ms | 30 MB + 188 KB | Accepted | Score: 4 | 显示更多 |