Pagini recente » Cod sursa (job #2869791) | Cod sursa (job #1703480) | Cod sursa (job #2945757) | Cod sursa (job #2677574) | Cod sursa (job #1692617)
#include <fstream>
//#include <iostream>
using namespace std;
ifstream cin ("hasuri.in");
ofstream cout("hasuri.out");
int n;
typedef struct nod{
int inf;
nod* next;
}* lista;
const int m=666013;
lista a[m];
void insert(int x){
int pz=x%m;
bool in=true;
for(lista p=a[pz]; p&∈ p=p->next) if(p->inf==x)in=false;
if(in) {
lista u=new nod;
u->inf=x;
u->next=a[pz];
a[pz]=u;
}
}
void delet(int x){
int pz=x%m;
for(lista p=a[pz],u=a[pz]; p; p=p->next)
{
if(p->inf==x){
if(p==a[pz])a[pz]=p->next;
else if(p->next) {
u->next=p->next;
}
else u->next=NULL;
}
u=p;
}
}
bool check(int x){
int pz=x%m;
for(lista p=a[pz]; p; p=p->next) if(p->inf==x) return 1;
return 0;
}
int main(){
cin >> n;
int x,o;
for(int i=0; i<n; i++){
cin >> o >> x;
if(o==1) insert(x);
if(o==2) delet(x);
if(o==3) cout << check(x) << "\n";
}
return 0;
}