Pagini recente » Cod sursa (job #2574195) | Cod sursa (job #2074577) | Cod sursa (job #1950847) | Cod sursa (job #1369081) | Cod sursa (job #2749946)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
class MyUnorderedMap {
vector<int> umap[666013];
public:
void insert(int x){
int sertar=x%666013;
for(int i=0;i<umap[sertar].size();i++){
if(x==umap[sertar][i]){
return;
}
}
umap[sertar].push_back(x);
};
void erase(int x){
int sertar=x%666013,L=umap[sertar].size();
for(int i=0;i<L;i++){
if(x==umap[sertar][i]){
umap[sertar][i]=umap[sertar][L-1];
umap[sertar].pop_back();
return;
}
}
};
bool search(int x){
int sertar=x%666013;
for(int i=0;i<umap[sertar].size();i++){
if(x==umap[sertar][i]){
return true;
}
}
return false;
};
};
int main(){
int n,i,x,y;
MyUnorderedMap v;
fin>>n;
for(i=1;i<=n;i++){
fin>>x>>y;
if(x==1){
v.insert(y);
}else{
if(x==2){
v.erase(y);
}else{
if(x==3){
int ok=v.search(y);
if(ok==true) fout<<1<<"\n";
else fout<<0<<"\n";
}
}
}
}
return 0;
}