Pagini recente » Cod sursa (job #479789) | Cod sursa (job #3002981) | Cod sursa (job #645480) | Cod sursa (job #903905) | Cod sursa (job #432185)
Cod sursa(job #432185)
#include <cstdio>
#include <vector>
#define q 4000001
#define p 1000007
#define r 4000003
using namespace std;
int n;
vector <pair <int,int> > hash[p];
void push(int x)
{
int i;
for (i=0;i<hash[x%p].size()&&hash[x%p][i].first!=x%r&&hash[x%p][i].second!=x%q;++i);
if (i==hash[x%p].size())
hash[x%p].push_back(make_pair(x%r,x%q));
}
void pop(int x)
{
int i;
for (i=0;i<hash[x%p].size()&&hash[x%p][i].first!=x%r&&hash[x%p][i].second!=x%q;++i);
if (i!=hash[x%p].size())
{
hash[x%p][i].first=-1;
hash[x%p][i].second=-1;
}
}
void query(int x)
{
int i;
for (i=0;i<hash[x%p].size()&&hash[x%p][i].first!=x%r&&hash[x%p][i].second!=x%q;++i);
if (i!=hash[x%p].size())
printf("%d\n",1);
else
printf("%d\n",0);
}
int main()
{
freopen ("hashuri.in","r",stdin);
freopen ("hashuri.out","w",stdout);
scanf("%d",&n);
int x,y;
while (n--)
{
scanf("%d%d",&y,&x);
if (y==1)
push(x);
if (y==2)
pop(x);
if (y==3)
query(x);
}
return 0;
}