Pagini recente » Cod sursa (job #929564) | Cod sursa (job #2347849) | Cod sursa (job #2344969) | Cod sursa (job #3040664)
#include <fstream>
#include <vector>
using namespace std;
ifstream in ("hashuri.in");
ofstream out ("hashuri.out");
const int mod = 666013;
vector <int> hsh[mod];
void ins (int x)
{
int baza = x % mod;
bool ok = false;
for (auto f : hsh[baza])
{
if (f == x)
{
ok = true;
break;
}
}
if (!ok)
{
hsh[baza].push_back(x);
}
}
void del (int x)
{
int baza = x % mod;
vector <int> :: iterator it = hsh[baza].begin();
while (it != hsh[baza].end())
{
if (*it == x)
{
hsh[baza].erase(it);
return;
}
it++;
}
}
int query (int x)
{
int baza = x % mod;
vector <int> :: iterator it = hsh[baza].begin();
while (it != hsh[baza].end())
{
if (*it == x)
{
return 1;
}
it++;
}
return 0;
}
int main ()
{
int q;
in >> q;
while (q--)
{
int op, x;
in >> op >> x;
if (op == 1)
{
ins(x);
}
if (op == 2)
{
del(x);
}
if (op == 3)
{
out << query(x) << '\n';
}
}
in.close();
out.close();
return 0;
}