Pagini recente » Cod sursa (job #3259379) | Cod sursa (job #1697099) | Cod sursa (job #169695) | Cod sursa (job #799375) | Cod sursa (job #3162432)
#include<bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n, c, x;
const int mod = 9999997;
vector<int> h[mod+1];
void addHash(int val){
int e = val&mod;
bool flag = true;
for(int i=0; i<h[e].size(); i++){
//cout<<i<<"/"<<h[e].size()-1<<"\n";
if(h[e][i] == val) flag = false;
}
if(flag) h[e].push_back(val);
}
void delHash(int val){
int e = val&mod;
for(int i=0; i<h[e].size(); i++){
//cout<<i<<"/"<<h[e].size()-1<<"\n";
if(h[e][i] == val){
swap(h[e][i], h[e][h[e].size()-1]);
h[e].pop_back();
}
}
}
void queHash(int val){
int e = val&mod;
for(int i=0; i<h[e].size(); i++){
//cout<<i<<"/"<<h[e].size()-1<<"\n";
if(h[e][i] == val){
fout<<1<<"\n"; return;
}
}
fout<<0<<"\n";
}
int main(){
fin>>n;
for(int i=1; i<=n; i++){
fin>>c>>x;
//cout<<c<<" "<<x<<"------------------------------\n";
if(c==1) addHash(x);
if(c==2) delHash(x);
if(c==3) queHash(x);
}
}