Pagini recente » Cod sursa (job #253089) | Cod sursa (job #2799129) | Cod sursa (job #279933) | Cod sursa (job #1950318) | Cod sursa (job #2702687)
#include <fstream>
#include <vector>
using namespace std;
const int MOD = 914239;
int n;
vector<int> a[MOD];
vector<int>::iterator find(int x) {
vector<int>::iterator it;
int lista = x % MOD;
for (it = a[lista].begin(); it < a[lista].end(); it++)
if (*it == x)
return it;
return a[lista].end();
}
void adauga(int x) {
int lista = x % MOD;
if (find(x) == a[lista].end())
a[lista].emplace_back(x);
}
void sterge(int x) {
int lista = x % MOD;
vector<int>::iterator it;
it = find(x);
if (it != a[lista].end())
a[lista].erase(it);
}
int main() {
int i, x, op;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f >> n;
for (i = 1; i <= n; i++) {
f >> op >> x;
if (op == 1)
adauga(x);
else if (op == 2)
sterge(x);
else
g << (find(x) != a[x % MOD].end()) << '\n';
}
f.close();
g.close();
return 0;
}