Pagini recente » Cod sursa (job #1679916) | Cod sursa (job #1805927) | Cod sursa (job #1107967) | Cod sursa (job #767405) | Cod sursa (job #1438216)
#include <stdio.h>
#include <vector>
#define MOD 666013
using namespace std;
//ifstream in("hashuri.in");
//ofstream out("hashuri.out");
int n, op, val;
vector<int> h[MOD];
vector<int>::iterator find_it(int key, int value)
{
for (auto it = h[key].begin(); it != h[key].end(); ++it)
{
if (*it == value)
{
return it;
}
}
return h[key].end();
}
bool find(int value)
{
int key = value % MOD;
return find_it(key, value) != h[key].end();
}
void insert(int value)
{
int key = value % MOD;
if (!find(value))
{
h[key].push_back(value);
}
}
void remove(int value)
{
int key = value % MOD;
auto pos = find_it(key, value);
if (pos != h[key].end())
{
h[key].erase(pos);
}
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
//in >> n;
scanf("%d", &n);
while (n--)
{
//in >> op >> val;
scanf("%d%d", &op, &val);
if (op == 1)
{
insert(val);
}
else
{
if (op == 2)
{
remove(val);
}
else
{
//out << find(val) << "\n";
if (find(val))
{
printf("1\n");
}
else
{
printf("0\n");
}
}
}
}
return 0;
}