Pagini recente » Cod sursa (job #1974566) | Cod sursa (job #2019851) | Profil RazielZ | Cod sursa (job #2007802) | Cod sursa (job #771284)
Cod sursa(job #771284)
#include<cstdio>
#include<vector>
#define pb push_back
#define Mod 666013
using namespace std;
vector <int> H[Mod];
vector <int> :: iterator it;
int i,n,IND,op,x;
void if_x (int x)
{
bool ok=false;
for (it=H[IND].begin();it<H[IND].end();it++)
if (*it==x) { ok=true;
break;
}
printf("%d\n",ok);
}
void push_x (int x)
{
if (it==H[IND].end()) H[IND].pb(x);
}
void del_x (int x)
{
if (it!=H[IND].end()) H[IND].erase(it);
}
vector <int> :: iterator find_x (int x)
{
for(it= H[IND].begin(); it!=H[IND].end(); it++)
if (*it==x) return it;
return it;
}
int main()
{
freopen ("hashuri.in","r",stdin);
freopen ("hashuri.out","w",stdout);
scanf("%d",&n);
for (i=1;i<=n;i++)
{
scanf("%d %d",&op,&x);
IND=x%Mod;
it=find_x(x);
if (op==1) push_x(x);
if (op==2) del_x(x);
if (op==3) if_x(x);
}
return 0;
}