Pagini recente » Cod sursa (job #752162) | Cod sursa (job #1226100) | Cod sursa (job #2057534) | Cod sursa (job #1908942) | Cod sursa (job #1112350)
#include <fstream>
#include <algorithm>
#include <set>
using namespace std;
class Hash {
public:
Hash() {}
void Insert(const int value) {
table[GetKey(value)].insert(value);
}
bool Find(const int value) const {
return (table[GetKey(value)].count(value) > 0);
}
void Erase(const int value) {
table[GetKey(value)].erase(value);
}
private:
static const int U = 666013;
set<int> table[U];
static int GetKey(const int value) {
return value % U;
}
};
int main() {
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
Hash hash;
int q;
cin >> q;
for (; q > 0; --q) {
int type, value;
cin >> type >> value;
if (type == 1)
hash.Insert(value);
else if (type == 2)
hash.Erase(value);
else if (type == 3)
cout << hash.Find(value) << "\n";
}
cin.close();
cout.close();
return 0;
}