Pagini recente » Profil eu3neuom | Cod sursa (job #426843) | Monitorul de evaluare | carburanti | Cod sursa (job #1774584)
#include<cstdio>
using namespace std;
const int prim=101,mod=1<<22;
int hash_v[mod],x,y;
void acum(int &y)
{
if(++y==mod) y=0;
}
int asa(int x)
{
int y=(1LL*x*prim)%mod;
for(;hash_v[y]!=x && hash_v[y]!=0;acum(y));
if(hash_v[y]==x) return y;
else return -1;
}
void baga(int x)
{
if(asa(x)!=-1) return;
int y=(1LL*x*prim)%mod;
for(;hash_v[y]!=x && hash_v[y]>0;acum(y));
hash_v[y]=x;
}
void scoate(int x)
{
int poz=asa(x);
if(poz!=-1)
{
hash_v[poz]=-1;
}
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int n,a,b,i;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&a,&b);
if(a==1)
{
baga(b);
}
else if(a==2)
{
scoate(b);
}
else if(asa(b)==-1)
{
printf("0\n");
}
else
{
printf("1\n");
}
}
}