Pagini recente » Cod sursa (job #2013083) | Cod sursa (job #1644770) | Clasament dupa rating | Cod sursa (job #2751685) | Cod sursa (job #1216864)
#include<cstdio>
#include<vector>
#define H 71993
using namespace std;
vector<int> A[H];
vector<int>::iterator hashFind(int);
void hashAdd(int), hashRemove(int);
int x,t,i,n;
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for(;n;n--)
{
scanf("%d%d",&t,&x);
if(t == 1)
{
hashAdd(x);
continue;
}
if(t == 2)
{
hashRemove(x);
continue;
}
if(t == 3)
{
if(hashFind(x) == A[x%H].end())
printf("0\n");
else
printf("1\n");
continue;
}
}
return 0;
}
vector<int>::iterator hashFind(int X)
{
int L = X % H;
vector<int>::iterator it;
for(it = A[L].begin(); it != A[L].end(); it ++)
if(*it == X)
return it;
return A[L].end();
}
void hashAdd(int X)
{
int L = X % H;
if(hashFind(X) == A[L].end())
A[L].push_back(X);
}
void hashRemove(int X)
{
int L = X % H;
vector<int>::iterator it;
it = hashFind(X);
if(it != A[L].end())A[L].erase(it);
}