Pagini recente » Cod sursa (job #1187403) | Cod sursa (job #1219345) | Cod sursa (job #3206375) | Cod sursa (job #83477) | Cod sursa (job #1550063)
#include <stdio.h>
#include <stdlib.h>
#define N 666013
#define M 1000000
struct{
int val,prec;
}v[M];
int h[N];
int lenv;
int poz;
int cauta(int nr,int rest){
poz=h[rest];
do{
if(v[poz].val==nr){
return 1;
}
poz=v[poz].prec;
}while(v[poz].prec);
return 0;
}
void op_1(int nr){
int rest=nr%N,t;
t=cauta(nr,rest);
if(t==0){
v[lenv].val=nr;
v[lenv].prec=h[rest];
h[rest]=lenv;
lenv++;
}
}
void op_2(int nr){
int rest=nr%N,t;
t=cauta(nr,rest);
if(t==0){
return;
}else{
v[poz].val=-1;
}
}
int main(){
int i,n,nr,op;
int rest;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d",&op,&nr);
if(op==1){
op_1(nr);
}else if(op==2){
op_2(nr);
}else{
rest=nr%N;
printf("%d\n",cauta(nr,rest));
}
}
return 0;
}