Pagini recente » Cod sursa (job #140710) | Clasamentul arhivei educationale | Cod sursa (job #605157) | Cod sursa (job #1563935) | Cod sursa (job #644348)
Cod sursa(job #644348)
#include <cstdio>
#include <vector>
using namespace std;
int i,j,k,l,m,n;
vector<int> g[666013];
inline vector<int>::iterator Find(int x)
{
int l=x%666013;
vector<int>::iterator it;
for(it=g[l].begin();it!=g[l].end();it++)
{
if (*it==x)
return it;
}
return g[l].end();
}
inline void Insert(int k)
{
l=k%666013;
if (Find(k)==g[l].end())
g[l].push_back(k);
}
inline void Delete(int k)
{
l=k%666013;
vector<int>::iterator it =Find(k);
if (it != g[l].end())
g[l].erase(it);
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
int x,y;
scanf("%d %d",&x,&y);
if(x==1)
{
Insert(y);
}
else if(x==2)
{
Delete(y);
}
else
{
printf("%d\n",Find(y)!=g[y%666013].end());
}
}
return 0;
}