Pagini recente » Cod sursa (job #2112714) | Cod sursa (job #1900335) | Cod sursa (job #1783695) | Cod sursa (job #528543) | Cod sursa (job #1451591)
#include<bits/stdc++.h>
using namespace std;
typedef struct lnod {
int info;
lnod *next;
}*nod;
const int MOD=666013;
int i,t,op,x;
nod H[666015];
bool Find(int x) {
for(nod p=H[x%MOD];p;p=p->next)
if(p->info==x) return 1;
return 0;
}
void add(int x,nod &y) {
nod p=new lnod;
p->info=x;
p->next=y;
y=p;
}
void del(int x) {
for(nod p=H[x%MOD],it=p;p;it=p,p=p->next)
if(p->info==x)
{
it->next=p->next;
delete p;
return ;
}
}
int main()
{
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
ios_base::sync_with_stdio(0); cin.tie(0);
for(cin>>t;t;--t)
{
cin>>op>>x;
if(op==1) if(!Find(x)) add(x,H[x%MOD]);
if(op==2) if(Find(x)) del(x);
if(op==3) cout<<Find(x)<<'\n';
}
return 0;
}