Pagini recente » Istoria paginii utilizator/ene_orlando_georgian_321cb | Cod sursa (job #2851699) | Cod sursa (job #1713307) | Cod sursa (job #1075598) | Cod sursa (job #2065316)
#include <iostream>
#include <fstream>
#include <vector>
#define max 666013
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n, o, x;
vector <int> H[max];
void adaug (int x)
{
int ind = x%max;
bool ok = 0;
for (int i = 0; i < H[ind].size(); i++)
if (H[ind][i] == x)
{
ok = 1;
i = int(H[ind].size());
}
if (ok == 0) H[ind].push_back(x);
}
void scot (int x)
{
int ind = x%max;
bool ok = 0;
for (int i = 0; i < H[ind].size(); i++)
{
if (H[ind][i] == x) ok = 1;
if (ok == 1) H[ind][i] = H[ind][i+1];
}
if (H[ind].size() > 0) H[ind].pop_back();
}
bool este (int x)
{
int ind = x%max;
bool r = 0;
for (int i = 0; i < H[ind].size(); i++)
if (H[ind][i] == x)
{
r = 1;
i = int(H[ind].size());
}
return r;
}
int main () {
fin >> n;
for (int i = 1; i <= n; i++)
{
fin >> o >> x;
if (o == 1) adaug(x);
if (o == 2) scot(x);
if (o == 3) fout << este(x) << "\n";
}
}