Pagini recente » Cod sursa (job #2730161) | Cod sursa (job #2286354) | Cod sursa (job #2352327) | Cod sursa (job #302363) | Cod sursa (job #1265387)
#include<stdio.h>
#include<vector>
using namespace std;
#define MOD 666013
vector <int> v[MOD];
inline int key(int x)
{
return x % MOD;
}
inline vector <int>::iterator cautihash (int x)
{
int ind = key(x);
vector <int>::iterator it;
for(it=v[ind].begin();it!=v[ind].end();++it)
{
if(*it==x)
return it;
}
return v[ind].end();
}
inline void bagihash (int x)
{
int ind = key(x);
if( cautihash(x) == v[ind].end() )
v[ind].push_back(x);
}
inline void lasihash (int x)
{
int ind = key(x);
vector <int>::iterator it=cautihash(x);
if(it!=v[ind].end())
v[ind].erase(it);
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
int n,op,x;
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d %d",&op, &x);
if(op==1)
bagihash(x);
if(op==2)
lasihash(x);
if(op==3)
printf("%d\n", cautihash(x) != v[key(x)].end() );
}
}