Pagini recente » Cod sursa (job #524666) | Cod sursa (job #2130312) | Cod sursa (job #991594) | Cod sursa (job #2394931) | Cod sursa (job #573199)
Cod sursa(job #573199)
#include<cstdio>
#include<vector>
#include<cmath>
#define M 999961
#define P 999979
#define Q 999983
#define cond (m[hashM] >= 1 && p[hashP] >= hashP/5672893 && q[hashQ] >= hashQ/1000003)
using namespace std;
size_t N;
size_t m[2*M],p[2*P],q[Q];
void adauga(size_t x){
size_t hashM=(x+7)%M;
size_t hashP=(x+13)%P;
size_t hashQ=x%Q;
if(!(cond))
m[hashM]+=1,
p[hashP]+=hashP/567893,
q[hashQ]+=hashQ/1000003;
}
void sterge(size_t x){
size_t hashM=(x+7)%M;
size_t hashP=(x+13)%P;
size_t hashQ=x%Q;
if(cond)
m[hashM]-=1,
p[hashP]-=hashP/567893,
q[hashQ]-=hashQ/1000003;
}
int main(){
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&N);
for(size_t i=1;i<=N;++i){
size_t tip,x;
scanf("%d%d",&tip,&x);
switch(tip){
case 1: adauga(x);
break;
case 2: sterge(x);
break;
case 3:
size_t hashM=(x+7)%M;
size_t hashP=(x+13)%P;
size_t hashQ=x%Q;
printf("%d\n",cond);
}
}
return 0;
}