Pagini recente » Cod sursa (job #356852) | Cod sursa (job #604877) | Cod sursa (job #2681808) | Cod sursa (job #212720) | Cod sursa (job #1970119)
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000001;
const int MOD = 666013;
vector<int> h[MOD];
bool hash_find(int nod){
int where = nod % MOD;
return find(h[where].begin(), h[where].end(), nod) != h[where].end();
}
void hash_insert(int nod){
int where = nod % MOD;
if(!hash_find(nod)){
h[where].push_back(nod);
}
}
void hash_remove(int nod){
int where = nod % MOD;
auto it = find(h[where].begin(), h[where].end(), nod);
if(it == h[where].end())
return;
h[where].erase(it);
}
int q;
int main(){
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
scanf("%d ", &q);
while(q--){
int op, param;
scanf("%d %d", &op, ¶m);
if(op == 1){
hash_insert(param);
} else if(op == 2){
hash_remove(param);
} else {
printf("%d\n", hash_find(param));
}
}
}