Pagini recente » Cod sursa (job #228454) | Cod sursa (job #3124020) | Cod sursa (job #2835273) | Cod sursa (job #790016) | Cod sursa (job #239303)
Cod sursa(job #239303)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
using namespace std;
#define HMAX 700001
list<int> a[HMAX];
int N, op, x;
inline int hp(int x)
{
while (x >= HMAX) x-= HMAX;
}
int find(int x)
{
int p = hp(x);
for (list<int> :: iterator it = a[p].begin(); it != a[p].end(); it++)
if (*it == x)
return 1;
return 0;
}
inline void add(int x)
{
if (!find(x)) a[hp(x)].push_back(x);
}
inline void remove(int x)
{
a[hp(x)].remove(x);
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
scanf("%d", &N);
for (int i = 0; i < N; i++)
{
scanf("%d %d", &op, &x);
if (op == 1)
add(x);
else if (op == 2)
remove(x);
else
printf("%d\n", find(x));
}
return 0;
}