Pagini recente » Cod sursa (job #558468) | Cod sursa (job #1710278) | Cod sursa (job #1719401) | Cod sursa (job #823948) | Cod sursa (job #1521366)
#include <cstdio>
#include <set>
#define MAXH 666013
using namespace std;
int T;
set<int> table[MAXH];
inline int hashFunction(int val) {
return val % MAXH;
}
void insert(int val) {
int h = hashFunction(val);
table[h].insert(val);
}
void remove(int val) {
int h = hashFunction(val);
table[h].erase(val);
}
bool find(int val) {
int h = hashFunction(val);
return table[h].find(val) != table[h].end();
}
int main() {
freopen ("hashuri.in", "r", stdin);
freopen ("hashuri.out", "w",stdout);
int op, val;
scanf ("%d\n", &T);
while (T--) {
scanf ("%d %d\n", &op, &val);
if (op == 1) {
insert(val);
}
if (op == 2) {
remove(val);
}
if (op == 3) {
printf ("%d\n", find(val));
}
}
}