Pagini recente » Cod sursa (job #893524) | Cod sursa (job #1465262) | Cod sursa (job #682709) | Cod sursa (job #2023276) | Cod sursa (job #2742799)
#include <iostream>
#include <fstream>
#include <vector>
#define prime 666013
using namespace std;
vector<int> hashh[prime];
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
void add(int x)
{
hashh[x % prime].push_back(x);
}
void del(int x)
{
for (int i = 0; i < hashh[x % prime].size(); i++)
{
if (hashh[x % prime][i] == x)
{
hashh[x % prime][i] = hashh[x % prime][hashh[x % prime].size() - 1];
hashh[x % prime].pop_back();
break;
}
}
}
bool get(int x)
{
for (int i = 0; i < hashh[x % prime].size(); i++)
{
if (hashh[x % prime][i] == x)
return true;
}
return false;
}
int main()
{
int n, op, x;
fin >> n;
for (int i = 0; i < n; i++)
{
fin >> op >> x;
if (op == 1)
{
add(x);
}
else if (op == 2)
{
del(x);
}
else
{
if (get(x))
{
fout << 1 << "\n";
}
else
{
fout << 0 << "\n";
}
}
}
return 0;
}