Pagini recente » Cod sursa (job #2549234) | Cod sursa (job #1691534) | Cod sursa (job #2903665) | Cod sursa (job #2601190) | Cod sursa (job #1309226)
#include <cstdio>
#include <vector>
#define pb push_back
#define mod 666013
using namespace std;
int i, n, type, x;
vector<int>hash[mod];
inline vector<int>::iterator find_value(int x)
{
int list=x%mod;
vector<int>::iterator it;
for(it=hash[list].begin(); it!=hash[list].end(); ++it)
if(*it==x) return it;
return hash[list].end();
}
inline void insert_value(int x)
{
int list=x%mod;
if(find_value(x)==hash[list].end())
hash[list].pb(x);
}
inline void erase_value(int x)
{
int list=x%mod;
vector<int>::iterator it=find_value(x);
if(it!=hash[list].end()) hash[list].erase(it);
}
int main()
{
freopen("hashuri.in", "rt", stdin);
freopen("hashuri.out", "wt", stdout);
scanf("%d", &n);
for(i=1; i<=n; ++i)
{
scanf("%d%d", &type, &x);
if(type==1)
{
insert_value(x);
continue;
}
if(type==2)
{
erase_value(x);
continue;
}
printf("%d\n", find_value(x)!=hash[x%mod].end());
}
return 0;
}