Pagini recente » Cod sursa (job #1480763) | Cod sursa (job #2784308) | Cod sursa (job #2789120) | Cod sursa (job #2297194) | Cod sursa (job #2622255)
#include <vector>
#include <fstream>
#define MOD 999983
using namespace std;
vector<int> map[MOD];
vector<int>::iterator find(int x) {
int hash = x % MOD;
vector<int>::iterator it;
for(it = map[hash].begin(); it != map[hash].end(); ++it)
if(*it == x)
return it;
return map[hash].end();
}
void insert(int x) {
int hash = x % MOD;
if(find(x) == map[hash].end())
map[hash].push_back(x);
}
void erase(int x) {
int hash = x % MOD;
auto it = find(x);
if(it != map[hash].end())
map[hash].erase(it);
}
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) != map[x % MOD].end()) << endl;
}
return 0;
}