Pagini recente » Cod sursa (job #1534552) | Cod sursa (job #2709989) | Cod sursa (job #127089) | Cod sursa (job #1784945) | Cod sursa (job #1066918)
#include<fstream>
#include <stdio.h>
#include<algorithm>
#include<vector>
#define mkp make_pair
#define pb push_back
using namespace std;
const int maxn = 1000;
const int M = 1000;
typedef int arrr[maxn];
arrr hash[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(hash[x][j] == a/M){
return;
}
}
hash[x][++nr[x]-1]=y;
}
void sterge(int a){
int x=a%M;
for(int j=0;j<nr[x];j++){
if(hash[x][j]== a/M){
swap(hash[x][j],hash[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(hash[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();
}