Pagini recente » Cod sursa (job #2241193) | Cod sursa (job #1323839) | Cod sursa (job #2251339) | Cod sursa (job #1643687) | Cod sursa (job #1047188)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
#define m 666013
#define k x % m
vector<int> h[m];
int cauta(int x)
{
for (vector<int> ::iterator i = h[k].begin(); i != h[k].end(); i ++)
if (*i == x)
return i - h[k].begin();
return -1;
}
void inserare(int x)
{
if (cauta(x) == -1)
h[k].push_back(x);
}
void stergere(int x)
{
int p = cauta(x);
if (p != -1)
{
h[k][p] = h[k].back();
h[k].pop_back();
}
}
int main()
{
int n, a, b;
in >> n;
while (n)
{
in >> a >> b;
if (a == 1)
inserare(b);
else if (a == 2)
stergere(b);
else if (a == 3)
{
if (cauta(b) == -1)
out << 0 << "\n";
else
out << 1 << "\n";
}
n--;
}
in.close();
out.close();
return 0;
}