Pagini recente » Cod sursa (job #632238) | Cod sursa (job #1804083) | Cod sursa (job #1622406) | Cod sursa (job #1891880) | Cod sursa (job #2733445)
#include <bits/stdc++.h>
#define MOD 666013
using namespace std;
ifstream fin("hashuri.in");
ofstream gout("hashuri.out");
int n, x, op;
vector <int> hash_table[666013];
void inserare (vector <int> v[], int x)
{
int poz = x % MOD;
if (find(v[poz].begin(), v[poz].end(), x) == v[poz].end())
v[poz].push_back(x);
}
void stergere (vector <int> v[], int x)
{
int poz = x % MOD;
if (find(v[poz].begin(), v[poz].end(), x) != v[poz].end())
{
vector <int>::iterator it;
it = find(v[poz].begin(), v[poz].end(), x);
int gasit = it - v[poz].begin();
v[poz].erase(v[poz].begin() + gasit);
}
}
bool cautare (vector <int> v[], int x)
{
int poz = x % MOD;
if (find(v[poz].begin(), v[poz].end(), x) == v[poz].end())
return 0;
return 1;
}
int main()
{
fin >> n;
for(int t = 0 ; t < n ; ++t)
{
fin >> op;
fin >> x;
switch (op)
{
case 1:
{
inserare(hash_table, x);
break;
}
case 2:
{
stergere(hash_table, x);
break;
}
case 3:
{
gout << cautare(hash_table, x) << "\n";
break;
}
}
}
return 0;
}