Pagini recente » Cod sursa (job #193168) | Cod sursa (job #1459259) | Cod sursa (job #299632) | Cod sursa (job #70739) | Cod sursa (job #1233034)
#include <iostream>
#define in "hashuri.in","r",stdin
#define out "hashuri.out","w",stdout
#include <cstdio>
#define nmax 1000001
using namespace std;
struct nod{
int e;
nod *next;
};
int n,h;
nod *H[nmax];
void Init(){
for(int i = 0; i < n; i++)
H[i] = NULL;
}
int lsearch(int x,long long k){
nod *L;
for(L = H[x];L!=NULL;L=L->next) if(L->e == k) return 1;
if(L==NULL) return 0;
return 1;
}
inline int h1(int x){
return x/n;
}
void add(long long x,int poz){
nod *L;
L=new nod;
L->e = x;
L->next = H[poz];
H[poz] = L;
}
void sterge(long long x , int poz){
nod *L;
L=new nod;
int ok = 1;
if(H[poz] != NULL&&H[poz]->e == x){
H[poz] = H[poz]->next;
}
else{
// cout << x <<' ';
if(H[poz]!=NULL){
nod *p;
p=new nod;
p = H[poz];
// while(p->next->e!=x &&p)
// p=p->next;
//cout << x <<' '<<p->e<<'\n';
// p->next = p->next->next;
}}
}
void Read(){
int x,cod;
freopen(in);
freopen(out);
scanf("%d",&n);
Init();
for(int i=1;i<=n;i++){
scanf("%d%d",&cod,&x);
if(cod == 1)
{
if(!lsearch(h1(x),x)) add(x,h1(x));
}
else if(cod == 2) sterge(x,h1(x));
else if(cod == 3 ) {
if(lsearch(h1(x),x))
cout <<1<<'\n';
else cout << 0<<'\n';
}
}
}
int main(){
Read();
return 0;
}