Pagini recente » Cod sursa (job #2045337) | Cod sursa (job #1812945) | Cod sursa (job #1759746) | Cod sursa (job #2777514) | Cod sursa (job #1256010)
#include <iostream>
#include <fstream>
#include <set>
const int MOD = 666013;
class Hash {
private:
std::set<int> a[MOD];
public:
Hash() {
}
void insert(int x) {
int id = x % MOD;
a[id].insert(x);
}
void erase(int x) {
int id = x % MOD;
if (a[id].find(x) != a[id].end()) {
a[id].erase(a[id].find(x));
}
}
bool has(int x) {
int id = x % MOD;
if (a[id].find(x) != a[id].end()) {
return true;
}
return false;
}
};
std::ifstream f("hashuri.in");
std::ofstream g("hashuri.out");
Hash hash;
int main()
{
int n;
f >> n;
for (int i = 1; i <= n; i++) {
int op, x;
f >> op >> x;
if (op == 1) hash.insert(x);
if (op == 2) hash.erase(x);
if (op == 3) g << hash.has(x) << '\n';
}
f.close();
g.close();
return 0;
}