Pagini recente » Istoria paginii utilizator/cnfblorzi | Cod sursa (job #2146236) | Cod sursa (job #914250) | Cod sursa (job #1424603) | Cod sursa (job #2065328)
#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;
for (int i = 0; i < H[ind].size(); i++)
if (H[ind][i] == x)
return;
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 && i < H[ind].size()-1) H[ind][i] = H[ind][i+1];
}
}
bool este (int x)
{
int ind = x%max;
for (int i = 0; i < H[ind].size(); i++)
if (H[ind][i] == x)
return 1;
return 0;
}
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";
}
}