Pagini recente » Cod sursa (job #2089820) | Cod sursa (job #1480585) | Cod sursa (job #1695328) | Cod sursa (job #954439) | Cod sursa (job #1233278)
#include <cstdio>
#include <vector>
using namespace std;
const char Infile[]="hashuri.in";
const char OutFile[]="hashuri.out";
const int mod=666013;
vector<int> hashtable[mod];
vector<int>::iterator it;
int n,i,op;
inline vector<int>::iterator Find(int x)
{
int t=i%mod;
for(it=hashtable[t].begin();it!=hashtable[t].end();++it)
if(*it==x) return it;
return hashtable[t].end();
}
inline void ins(int x)
{
int t=i%mod;
for(it=hashtable[t].begin();it!=hashtable[t].end();++it)
if(*it==x) return;
hashtable[t].push_back(x);
}
inline void ers(int x)
{
int t=i%mod;
vector<int>::iterator aux=Find(x);
if(aux!=hashtable[t].end())
hashtable[t].erase(it);
}
int main()
{
freopen(Infile,"r",stdin);
freopen(OutFile,"w",stdout);
for(scanf("%d",&n);n;--n)
{
scanf("%d %d",&op,&i);
if(op==1)
{
ins(i);
continue;
}
if(op==2)
{
ers(i);
continue;
}
if(op==3)
{
if (Find(i)!=hashtable[i%mod].end())
printf("1\n");
else printf("0\n");
}
}
return 0;
}