Pagini recente » Cod sursa (job #275503) | Cod sursa (job #522208) | Cod sursa (job #243202) | Cod sursa (job #1153034) | Cod sursa (job #1472654)
#include <iostream>
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
vector <int> v[MOD];
inline vector <int> :: iterator find_hash(int x)
{
int pos=x%MOD;
vector <int> :: iterator it;
for(it=v[pos].begin();it<v[pos].end();it++)
if(*it==x)
return it;
return v[pos].end();
}
inline void insert_hash(int x)
{
int pos=x%MOD;
if(find_hash(x)==v[pos].end())
v[pos].push_back(x);
}
inline void del_hash(int x)
{
int pos=x%MOD;
vector <int> :: iterator it=find_hash(x);
if(it!=v[pos].end())
v[pos].erase(it);
}
int n,op,x;
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f>>n;
for(int i=1;i<=n;i++)
{
f>>op>>x;
if(op==1)
insert_hash(x);
else if(op==2)
del_hash(x);
else if(op==3)
{
if(find_hash(x)!=v[x%MOD].end())
g<<1<<'\n';
else
g<<0<<'\n';
}
}
g<<'\n';
f.close();
g.close();
return 0;
}