Pagini recente » Istoria paginii runda/igorj/clasament | Cod sursa (job #1288228) | Cod sursa (job #1300883) | Cod sursa (job #1179166) | Cod sursa (job #2065360)
#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()-2) H[ind][i] = H[ind][i+1];
}
if (H[ind].size()) H[ind].pop_back();
}
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";
}
}