Pagini recente » Cod sursa (job #344807) | Cod sursa (job #802611) | Cod sursa (job #1013994) | Cod sursa (job #172510) | Cod sursa (job #1089379)
#include<cstdio>
#include<vector>
using namespace std;
vector <int> ha[700001];
vector <int>:: iterator findpos(int x)
{
int li=x%700001;
vector <int>:: iterator it;
for(it=ha[li].begin(); it!=ha[li].end();it++)
if(*it==x)
return it;
return ha[li].end();
}
void insertv(int x)
{
int li=x%700001;
if(findpos(x)==ha[li].end())
ha[li].push_back(x);
}
void erasev(int x)
{
int li=x%700001;
vector <int>:: iterator it;
it=findpos(x);
if(it!=ha[li].end())
ha[li].erase(it);
}
int main()
{
int op,x,n,i;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d\n",&op,&x);
if(op==1)
insertv(x);
else
{
if(op==2)
erasev(x);
else
{
if(findpos(x)!=ha[x%700001].end())
printf("1\n");
else
printf("0\n");
}
}
}
fclose(stdin);
fclose(stdout);
return 0;
}