Pagini recente » Cod sursa (job #1894617) | Cod sursa (job #3181267) | Cod sursa (job #1372605) | Cod sursa (job #1235534) | Cod sursa (job #539157)
Cod sursa(job #539157)
#include <stdio.h>
#include <vector>
using namespace std;
vector <int> h[666013];
int n,i,j,a,b,ok,x,y;
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for (i=1;i<=n;++i)
{
scanf("%d%d",&x,&y);
if (x==1)
{
b=y%666013;a=h[b].size();ok=1;
for (j=0;j<a;++j)
if (h[b][j]==y) ok=0;
if (ok) h[b].push_back(y);
}
else if (x==2)
{
ok=-1;b=y%666013;a=h[b].size();
for (j=0;j<a;++j)
if (h[b][j]==y) ok=j;
if (ok!=-1)
{
h[b][ok]=h[b][a-1];
h[b].pop_back();
}
}
else
{
ok=0;b=y%666013;a=h[b].size();
for (j=0;(j<a)&&(!ok);++j)
if (h[b][j]==y)
ok=1;
printf("%d\n",ok);
}
}
return 0;
}