Pagini recente » Cod sursa (job #62055) | Cod sursa (job #1604907) | Cod sursa (job #248920) | Cod sursa (job #160356) | Cod sursa (job #1875053)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
const int mod = 666013;
class Hash {
private:
vector <int> V[mod + 1];
public:
inline vector <int> :: iterator Find(int val) {
int key = val & mod;
for (vector <int> :: iterator it = V[key].begin(); it != V[key].end(); it++) {
if (*it == val) {
return it;
}
}
return V[key].end();
}
inline bool Exist(int val) {
int key = val & mod;
return Find(val) != V[key].end();
}
inline void Insert(int val) {
int key = val & mod;
if (Find(val) == V[key].end()) {
V[key].push_back(val);
}
}
inline void Erase(int val) {
int key = val & mod;
vector <int> :: iterator pos = Find(val);
if (pos != V[key].end()) {
V[key].erase(pos);
}
}
} H;
int main() {
ios_base :: sync_with_stdio (false);
int n, op, val;
fin >> n;
while (n--) {
fin >> op >> val;
if (op == 1) {
H.Insert(val);
} else if (op == 2) {
H.Erase(val);
} else {
fout << H.Exist(val) << "\n";
}
}
fin.close();
fout.close();
return 0;
}