Pagini recente » Cod sursa (job #2673459) | Cod sursa (job #918323) | Cod sursa (job #1555638) | Cod sursa (job #2206109) | Cod sursa (job #286371)
Cod sursa(job #286371)
#include <cstdio>
#include <vector>
#define dim 666999
using namespace std;
int n;
vector<int> hash[dim];
vector<int>::iterator find(int x)
{
int l=x%dim;
vector<int>::iterator it;
for (it=hash[l].begin(); it!=hash[l].end(); it++)
if (*it==x) return it;
return hash[l].end();
}
void add(int x)
{
int l=x%dim;
if (find(x)==hash[l].end())
hash[l].push_back(x);
}
void del(int x)
{
int l=x%dim;
vector<int>::iterator it=find(x);
if (it!=hash[l].end())
hash[l].erase(it);
}
int main()
{
int op, x;
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
scanf("%d\n", &n);
for (; n; n--)
{
scanf("%d %d\n", &op, &x);
if (op==1)
{
add(x);
continue;
}
if (op==2)
{
del(x);
continue;
}
printf("%d\n", find(x)!=hash[x%dim].end());
}
return 0;
}