Pagini recente » Cod sursa (job #549543) | Cod sursa (job #2331840) | Istoria paginii monthly-2012 | Profil M@2Te4i | Cod sursa (job #1066921)
#include<fstream>
#include<algorithm>
using namespace std;
const int maxn = 1000;
const int M = 1000;
//typedef int arrr[maxn];
int hash1[maxn][maxn];
int nr[maxn];
//std::vector < pair<int,int> > hash[maxn];
void adauga(int a){
int x=a%M,y=a/M;
for(int j=0;j<nr[x];j++){
if(hash1[x][j] == a/M){
return;
}
}
hash1[x][++nr[x]-1]=y;
}
void sterge(int a){
int x=a%M;
for(int j=0;j<nr[x];j++){
if(hash1[x][j]== a/M){
swap(hash1[x][j],hash1[x][--nr[x]]);
//hash[a%M][j]=-1;
break;
}
}
}
int check(int a){
int x=a%M;
for(int j=0;j<nr[x];j++){
if(hash1[x][j] == a/M){
return 1;
break;
}
}
return 0;
}
main(){
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n,a,b;
for(int i=0;i<M;nr[++i]=0);
fin>>n;
for(int i=1;i<=n;i++){
fin>>a>>b;
if(a==1){
adauga(b);
}else if(a==2){
sterge(b);
}else{
fout<<check(b)<<"\n";
}
}
fin.close(); fout.close();
}