Pagini recente » Cod sursa (job #958761) | Cod sursa (job #253894) | Cod sursa (job #198106) | Cod sursa (job #64924) | Cod sursa (job #632095)
Cod sursa(job #632095)
#include <cstdio>
#include <vector>
#define Mod 666013
using namespace std;
int n,op,x,i,ind;
vector<int> h[Mod];
vector<int>::iterator it;
vector<int>::iterator findv(int x)
{
for (it=h[ind].begin() ; it!=h[ind].end() ;it++)
if (*it==x) return it;
return h[ind].end();
}
void insertv(int x)
{
if (it==h[ind].end()) h[ind].push_back(x);
}
void erasev(int x)
{
if (it!=h[ind].end()) h[ind].erase(it);
}
void writev(int x)
{
if (it!=h[ind].end()) printf("1\n");
else
printf("0\n");
}
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=findv(x);
if (op==1) insertv(x);
if (op==2) erasev(x);
if (op==3) writev(x);
}
}