Pagini recente » Cod sursa (job #2546342) | Cod sursa (job #1976026) | Cod sursa (job #1975760) | Cod sursa (job #862686) | Cod sursa (job #1198180)
#include<fstream>
#include<algorithm>
#define MOD 666013
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
typedef struct lnod {
int info;
lnod *next;
}*nod;
int n,tip,x;
nod a[666018];
bool u;
void add(int x,nod &y) {
nod p=new lnod;
p->info=x;
p->next=y;
y=p;
}
void del(int x) {
nod p=a[x%MOD],r;
while(p)
if(p->info==x) if(p==a[x]) if(p->next==NULL) { a[x]=NULL;delete p; return; }
else { a[x]=p->next;delete p; return; }
else {
r->next=p->next;
r=r->next;
delete p;
return;
}
else r=p,p=p->next;
}
bool find(int x) {
nod p;
for(p=a[x%MOD];p;p=p->next)
if(p->info==x) return 1;
return 0;
}
int main()
{
cin>>n;
while(n--)
{
cin>>tip>>x;
u=find(x);
if(tip==1 && !u) add(x,a[x%MOD]);
if(tip==2 && u) del(x);
if(tip==3) cout<<u<<'\n';
}
return 0;
}