Pagini recente » Cod sursa (job #1633322) | Cod sursa (job #688174) | Cod sursa (job #3292253) | Cod sursa (job #968718) | Cod sursa (job #2231896)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int Mod = 102653;
vector <int> HashMap[Mod];
inline void Insert(vector <int> HashMap[Mod], const int &x) {
for (const int &itm : HashMap[x % Mod])
if (itm == x) return;
HashMap[x % Mod].push_back(x);
}
inline void Erase(vector <int> HashMap[Mod], const int &x) {
for(auto it = HashMap[x % Mod].begin(); it != HashMap[x % Mod].end(); ++it)
if (*it == x) {
HashMap[x % Mod].erase(it);
return ;
}
}
inline bool Search(vector <int> HashMap[Mod], const int &x) {
for (const int &itm : HashMap[x % Mod])
if (itm == x)
return true;
return false;
}
int main() {
int Q;
fin >> Q;
for (; Q; --Q) {
int code, x;
fin >> code >> x;
if (code == 1)
Insert(HashMap, x);
else if (code == 2)
Erase(HashMap, x);
else fout << Search(HashMap, x) << '\n';;
}
}