Pagini recente » Borderou de evaluare (job #2683090) | Cod sursa (job #3265623) | Cod sursa (job #1826905) | Cod sursa (job #635453) | Cod sursa (job #904904)
Cod sursa(job #904904)
#include<cstdio>
#include<list>
#define M 666013
using namespace std;
list <int> a[M+5];
list <int>::iterator it;
list <int>::iterator loc (int x)
{
list <int>::iterator itt;
for (it=a[x%M].begin(); it!=a[x%M].end(); ++it)
if (*it==x)
return it;
return a[x%M].end();
}
void add (int x)
{
if (!a[x%M].size())
a[x%M].push_back(x);
else
{
it=loc(x);
if (it!=a[x%M].end())
a[x%M].push_back(x);
}
}
void erase (int x)
{
if (a[x%M].size())
{
it=loc(x);
if (it!=a[x%M].end())
a[x%M].erase(it);
}
}
int multime (int x)
{
if (a[x%M].size())
if (it!=a[x%M].end())
return 1;
return 0;
}
int main ()
{
int n,tip,x;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
while (n--)
{
scanf("%d%d",&tip,&x);
if (tip==1)
add(x);
else if (tip==2)
erase(x);
else
printf("%d\n",multime(x));
}
return 0;
}