Pagini recente » Cod sursa (job #2338830) | Cod sursa (job #255868) | Cod sursa (job #2296327) | Cod sursa (job #1127119) | Cod sursa (job #2533626)
#include <bits/stdc++.h>
template <int prime>
class HashSet {
public:
HashSet() {}
void insert(int value) { table[hash(value)].insert(value); }
void erase(int value) { table[hash(value)].erase(value); }
bool contains(int value) { return table[hash(value)].find(value) != table[hash(value)].end(); }
private:
std::set <int> table[prime];
inline int hash(int x) { return (x%prime + prime)%prime; }
}; HashSet <666013> set;
std::ifstream input ("hashuri.in");
std::ofstream output("hashuri.out");
int main()
{
int Q; input >> Q;
int op, x;
while (Q--) {
input >> op >> x;
if (op == 1) set.insert(x);
else if (op == 2) set.erase(x);
else if (op == 3) output << set.contains(x) << '\n';
}
return 0;
}