Pagini recente » Cod sursa (job #1244453) | Cod sursa (job #648048) | Cod sursa (job #2988275) | Cod sursa (job #1509658) | Cod sursa (job #1848606)
#include <stdio.h>
#include <vector>
using namespace std;
#define M 666013
vector<int> h[M];
inline vector<int>::iterator find_value(int x)
{
int ord = x % M;
vector<int>::iterator it;
for (it = h[ord].begin(); it != h[ord].end(); ++it)
if (*it == x)
return it;
return h[ord].end();
}
void add(int x)
{
int ord = x % M;
if (find_value(x) == h[ord].end())
h[ord].push_back(x);
}
void remove(int x)
{
int ord = x % M;
vector<int>::iterator it = find_value(x);
if (it != h[ord].end())
h[ord].erase(it);
}
int main()
{
int x, y, n;
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
scanf("%d", &n);
while(n--)
{
scanf("%d %d", &x, &y);
if (x == 1)add(y);
if (x == 2)remove(y);
if (x == 3) printf("%d\n", find_value(x) != h[x % M].end());
}
return 0;
}