Pagini recente » Cod sursa (job #114836) | Cod sursa (job #1812862) | Cod sursa (job #1968186) | Cod sursa (job #1726059) | Cod sursa (job #2368728)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
const int P = 666013;
vector <int> h[P];
bool Search (int x)
{
int r = x % P;
for (auto v : h[r])
if (v == x)
return true;
return false;
}
void Add (int x)
{
int r = x % P;
if (!Search(x))
h[r].push_back(x);
}
void Remove(int x)
{
int r = x % P, l;
l = h[r].size();
for (int i = 0; i < l; i++)
if (h[r][i] == x)
{
swap(h[r][i], h[r][l - 1]);
h[r].pop_back();
}
}
void Solve ()
{
int n, op, x;
fin >> n;
while (n--)
{
fin >> op >> x;
if (op == 1) Add(x);
if (op == 2) Remove(x);
if (op == 3) fout << Search(x) << "\n";
}
fout.close();
}
int main()
{
Solve();
return 0;
}