Pagini recente » Cod sursa (job #2862237) | Cod sursa (job #598939) | Cod sursa (job #2367947) | Cod sursa (job #763383) | Cod sursa (job #1040915)
#include<stdio.h>
#include<vector>
#define PRIM 666013
using namespace std;
vector<long> hash[PRIM];
long n, a[101][101];
vector<long>::iterator find_value(long x) {
long hValue = x % PRIM;
vector<long>::iterator it;
for(it = hash[hValue].begin(); it != hash[hValue].end(); ++it)
if(*it == x)
return it;
return hash[hValue].end();
}
void insert_value(long x) {
long hValue = x % PRIM;
if(find_value(x) == hash[hValue].end())
hash[hValue].push_back(x);
}
void erase_value(long x) {
long hValue = x % PRIM;
vector<long>::iterator it = find_value(x);
if(it != hash[hValue].end())
hash[hValue].erase(it);
}
int main() {
freopen("hashuri.in", "rt", stdin);
freopen("hashuri.out", "wt", stdout);
scanf("%ld", &n);
long x, op;
for(int i = 0; i < n; i++) {
scanf("%ld %ld", &op, &x);
if(op == 1) {
insert_value(x);
continue;
}
if(op == 2) {
erase_value(x);
continue;
}
printf("%d\n", find_value(x) != hash[x % PRIM].end());
}
return 0;
}