Pagini recente » Cod sursa (job #90972) | Cod sursa (job #1418620) | Cod sursa (job #136266) | Cod sursa (job #1232719) | Cod sursa (job #944437)
Cod sursa(job #944437)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
class HashSet {
public:
HashSet() {
table.resize(mod);
}
void insert( int x ) {
int r = x % mod;
table[r].insert(x);
}
void remove( int x ) {
int r = x % mod;
table[r].erase(x);
}
bool inSet( int x ) {
int r = x % mod;
return table[r].count(x);
}
private:
static const int mod = 666013;
vector<set<int> > table;
};
int main() {
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n;
fin >> n;
HashSet a;
for (int i = 0; i < n; ++i) {
int op, x;
fin >> op >> x;
switch (op) {
case 1: a.insert(x); break;
case 2: a.remove(x); break;
case 3: fout << a.inSet(x) << '\n'; break;
}
}
return 0;
}