Pagini recente » Cod sursa (job #2610589) | Cod sursa (job #396650) | Cod sursa (job #2469405) | Cod sursa (job #1817111) | Cod sursa (job #1583808)
#include <iostream>
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
int n;
vector<int> hash[MOD];
vector<int>::iterator find(int x)
{
int key = x%MOD;
vector<int>::iterator it;
for(it = hash[key].begin();it<hash[key].end();it++)
if(*it==x)
return it;
return hash[key].end();
}
void add(int x)
{
int key = x%MOD;
if(find(x)==hash[key].end())
hash[key].push_back(x);
}
void erase(int x)
{
int key = x%MOD;
vector<int>::iterator it;
it = find(x);
if(it!=hash[key].end())
hash[key].erase(find(x));
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
cin>>n;
int op,x;
for(int i=1;i<=n;i++)
{
cin>>op>>x;
if(op==1)
{
add(x);
continue;
}
if(op==2)
{
erase(x);
continue;
}
if(op==3)
cout<<((find(x)==hash[x%MOD].end()) ? 0:1)<<'\n';
}
return 0;
}