Pagini recente » Cod sursa (job #1894078) | Cod sursa (job #2242430) | Cod sursa (job #1069308) | Cod sursa (job #1852447) | Cod sursa (job #2622730)
#include <vector>
#include <fstream>
#define MOD 999983
using namespace std;
vector<int> map[MOD];
int find(int x) {
int hash = x % MOD;
vector<int>::iterator it;
for(int i = 0; i < map[hash].size(); i++)
if(map[hash][i] == x)
return i;
return -1;
}
void insert(int x) {
int hash = x % MOD;
if(find(x) == -1)
map[hash].push_back(x);
}
void erase(int x) {
int hash = x % MOD;
auto i = find(x);
if(i != -1)
map[hash].erase(map[hash].begin() + i);
}
int main() {
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int op, x, n;
fin >> n;
for(int i = 0; i < n; i++) {
fin >> op >> x;
if(op == 1) {
insert(x);
continue;
}
if(op == 2) {
erase(x);
continue;
}
fout << (find(x) != -1) << endl;
}
fin.close();
fout.close();
return 0;
}