Pagini recente » Cod sursa (job #1570960) | Cod sursa (job #1506323) | Cod sursa (job #3214973) | Cod sursa (job #851055) | Cod sursa (job #1155216)
#include <fstream>
#include <vector>
#define MAX 666133
using namespace std;
vector<int> hashs[MAX];
vector<int>::iterator findh(int val){
int pos = val % MAX;
vector<int>::iterator it;
for(it = hashs[pos].begin(); it < hashs[pos].end(); it++){
if(*it == val){
return it;
}
}
return hashs[pos].end();
}
void inserth(int val){
int pos = val % MAX;
if(findh(val) == hashs[pos].end())
hashs[pos].push_back(val);
}
void deleteh(int val){
int pos = val % MAX;
vector<int>::iterator it;
if((it = findh(val)) != hashs[pos].end()){
hashs[pos].erase(it);
}
}
int main(){
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n, op, val;
fin >> n;
for(int i = 0 ; i < n ; i++){
fin >> op >> val;
if(op == 1){
inserth(val);
}else{
if(op == 2){
deleteh(val);
}else{
//cout << op << val <<" ";
int ok = ((findh(val) == hashs[val % MAX].end())? 0 : 1);
fout << ok << "\n";
}
}
}
return 0;
}