Pagini recente » Cod sursa (job #1550848) | Cod sursa (job #1867270)
#include <cstdio>
#include <vector>
using namespace std;
vector <int>h[666017];
vector <int>::iterator it;
int i,n,x,y,ind;
void find_v(int x){
for(it=h[ind].begin();it!=h[ind].end();it++)
if(*it==x)return;
}
void insert_v(int x){
if(it==h[ind].end())
h[ind].push_back(x);
}
void erase_v(int x){
if(it!=h[ind].end())
h[ind].erase(it);
}
void write_v(int x){
if(it==h[ind].end())
printf("0\n");
else printf("1\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",&x,&y);
ind=y%666013;
find_v(y);
if(x==1)
insert_v(y);
else if(x==2)
erase_v(y);
else write_v(y);
}
return 0;
}