Pagini recente » Cod sursa (job #2091397) | Cod sursa (job #989598) | Cod sursa (job #301298) | Cod sursa (job #2726283) | Cod sursa (job #2622312)
#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;
}
return 0;
}