Pagini recente » Cod sursa (job #2048311) | Cod sursa (job #241836) | Cod sursa (job #1413729) | Cod sursa (job #319215) | Cod sursa (job #632094)
Cod sursa(job #632094)
#include <cstdio>
#include <vector>
#define Mod 666013
using namespace std;
vector<int> h[Mod];
vector<int>::iterator it;
int i,n,op,x,ind;
bool ok;
vector<int> :: iterator findv(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",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d\n",&op,&x);
ind=x%Mod;
it=findv(x);
if (it==h[ind].end()) ok=false;
else ok=true;
if(op==1&&!ok) h[ind].push_back(x);
if(op==2&&ok) h[ind].erase(it);
if(op==3)
{
if(ok) printf("1\n");
else printf("0\n");
}
}
fclose(stdin);fclose(stdout);
return 0;
}