Pagini recente » Cod sursa (job #1695164) | Cod sursa (job #2676152) | Cod sursa (job #28837) | Cod sursa (job #133832) | Cod sursa (job #291699)
Cod sursa(job #291699)
#include<fstream.h>
#define mod 666013
struct asd
{
int inf;
asd * next;
};
asd *a[mod+1];
int check (int x)
{
int p=x%mod;
for (asd *q=a[p]; q ;q=q->next)
if (q->inf==x) return 1;
return 0;
}
void add (int x)
{
int p=x%mod;
asd *q=new asd;
q->inf=x;
q->next=a[p];
a[p]=q;
}
void del (int x)
{
int p=x%mod;
for (asd *q=a[p]; q; q=q->next)
if (q->inf==x)
{ q->inf=0; return; }
}
int main()
{
int n,what,x;
ifstream be ("hashuri.in");
ofstream ki ("hashuri.out");
be>>n;
for (;n;--n)
{
be>>x>>what;
if (x==1) add(what);
if (x==2) del(what);
if (x==3) ki<<check(what)<<'\n';
}
be.close();
ki.close();
return 0;
}