Pagini recente » Cod sursa (job #476666) | Cod sursa (job #648173) | Cod sursa (job #2123858) | Cod sursa (job #410297) | Cod sursa (job #2627164)
#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() {
freopen("proc2.in", "r", stdin);
freopen("proc2.out", "w", stdout);
int op, x, n;
scanf("%d", &n);
for(int i = 0; i < n; i++) {
scanf("%d%d", &op, &x);
if(op == 1) {
insert(x);
continue;
}
if(op == 2) {
erase(x);
continue;
}
printf("%d\n", find(x) != -1);
}
return 0;
}