Pagini recente » Cod sursa (job #3219237) | Cod sursa (job #457147) | Cod sursa (job #1552535) | Cod sursa (job #918681) | Cod sursa (job #721359)
Cod sursa(job #721359)
#include <cstdio>
#include <vector>
using namespace std;
const int mod=666013;
vector<int> a[mod];
inline vector<int>::iterator find_v(int x)
{
int k = x % mod;
vector<int>::iterator it;
for (it = a[k].begin(); it != a[k].end(); ++it)
if (*it == x)
return it;
return a[k].end();
}
inline void insert_v(int x)
{
int k = x % mod;
vector<int>::iterator it = find_v(x);
if (it == a[k].end()) a[k].push_back(x);
}
inline void erase_v(int x)
{
int k = x % mod;
vector<int>::iterator it = find_v(x);
if (it != a[k].end()) a[k].erase(it);
}
int main()
{
int n, x, y;
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
for (scanf("%d", &n); n; --n)
{
scanf("%d %d", &y, &x);
if (y == 1)
{
insert_v(x);
continue;
}
if (y == 2)
{
erase_v(x);
continue;
}
printf("%d\n", find_v(x) != a[x % mod].end());
}
return 0;
}