Pagini recente » Cod sursa (job #2680524) | Cod sursa (job #2645972) | Cod sursa (job #3244969) | Cod sursa (job #1231107) | Cod sursa (job #1189057)
#include<cstdio>
using namespace std;
const int MAXN=1000001;
const int COMP=1<<19;
int val[MAXN];
int urm[MAXN];
int lst[COMP];
int nr;
void adauga(int x)
{
val[++nr]=x;
urm[nr]=lst[x%COMP];
lst[x%COMP]=nr;
}
void sterge(int x)
{
int p=lst[x%COMP];
if(val[p]==x)
{
lst[x%COMP]=urm[p];
}
else
{
while(urm[p]!=0&&val[urm[p]]!=x)
p=urm[p];
urm[p]=urm[urm[p]];
}
}
bool cauta(int x)
{
int p=lst[x%COMP];
while(p!=0&&val[p]!=x)
{
p=urm[p];
}
return p!=0;
}
int main()
{
int n,i,op,x;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d",&op,&x);
if(op==1)
{
adauga(x);
}
else if(op==2)
{
sterge(x);
}
else
{
printf("%d\n",cauta(x));
}
}
return 0;
}