Pagini recente » Cod sursa (job #570994) | Cod sursa (job #2776537) | Cod sursa (job #2929009) | Cod sursa (job #2966114) | Cod sursa (job #2742504)
#include <bits/stdc++.h>
using namespace std;
#define prim 99079
std::ifstream fin("hashuri.in");
std::ofstream fout("hashuri.out");
struct HashMap{
std::vector<int> Map[prim];
void adauga(int x){
int h = x%prim;
if(std::find(Map[h].begin(),Map[h].end(),x) == Map[h].end()){
Map[h].push_back(x);
}
}
void sterge(int x){
int h = x%prim;
auto elem = std::find(Map[h].begin(),Map[h].end(),x);
if(elem != Map[h].end()){
Map[h].erase(elem);
}
}
int cauta(int x){
int h = x%prim;
if(std::find(Map[h].begin(),Map[h].end(),x) != Map[h].end()){
return 1;
}
else{
return 0;
}
}
};
int n = 0;
int main(){
HashMap hashMap;
fin>>n;
for (int i = 0; i < n; i++){
int operatie, x;
fin>>operatie>>x;
switch(operatie){
case 1:
hashMap.adauga(x);
break;
case 2:
hashMap.sterge(x);
break;
case 3:
fout<<hashMap.cauta(x)<<endl;
break;
}
}
fin.close();
fout.close();
return 0;
}