Pagini recente » Cod sursa (job #3252350) | Cod sursa (job #1060589)
#include <cstdio>
#include <list>
using namespace std;
const int MOD=36013;
typedef list<int> hesh;
typedef hesh::iterator hit;
hesh ht[MOD+10];
hit find(int x)
{
for( hit i=ht[x%MOD].begin(); i!=ht[x%MOD].end(); i++)
if( x==*i )
return i;
return ht[x%MOD].end();
}
int main()
{
int n;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d", &n);
int op,param;
for(int i=1;i<=n;i++)
{
scanf("%d %d",&op,¶m);
hit cnt=find(param);
if(op==1)
{
if(cnt==ht[param%MOD].end())
ht[param%MOD].push_back(param);
}
else if(op==2)
{
if(cnt!=ht[param%MOD].end())
ht[param%MOD].erase(cnt);
}
else if(op==3)
{
if(cnt!=ht[param%MOD].end())
printf("%d \n",1);
else printf("%d \n",0);
}
}
return 0;
}