Pagini recente » Cod sursa (job #3207853) | Cod sursa (job #1871954) | Cod sursa (job #1628024) | Cod sursa (job #152375) | Cod sursa (job #359654)
Cod sursa(job #359654)
#include<stdio.h>
#include<vector>
using namespace std;
int n,h,hv,v,c;
vector<int> ht[100100];
void read(),solve();
int main()
{
read();
solve();
return 0;
}
void read()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
}
void solve()
{
h=100009;
vector<int>::iterator it;
for(;n;n--)
{
scanf("%d%d",&c,&v);
hv=v%h;
for(it=ht[hv].begin();it!=ht[hv].end();it++)
if(*it==v)
break;
if(c==1)
{
if(it==ht[hv].end())ht[hv].push_back(v);
}
else
{
if(c==2)
{
if(it!=ht[hv].end())
{
*it=ht[hv].back();
ht[hv].pop_back();
}
}
else
(it==ht[hv].end())?printf("0\n"):printf("1\n");
}
}
}