Pagini recente » Cod sursa (job #2889226) | Cod sursa (job #2904732) | Cod sursa (job #1003507) | Cod sursa (job #667841) | Cod sursa (job #2036816)
#include <vector>
#include <set>
#include <cstdio>
#include <algorithm>
const int M = 666013;
using namespace std;
vector< set<int> > v;
set<int>::iterator it;
int h(int n)
{
return n % M;
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int n, f, x, a;
scanf("%d", &n);
v.resize(M);
for(int i = 0; i < n; i++)
{
scanf("%d%d", &f, &x);
a = h(x);
if(f == 1)
{
v[a].insert(x);
}
else
{
it = find(v[a].begin(), v[a].end(), x);
}
if(f == 2)
{
if(it != v[a].end())
v[a].erase(x);
}
if(f == 3)
{
printf("%d\n", (it != v[a].end()));
}
}
return 0;
}