Pagini recente » Cod sursa (job #1479868) | Cod sursa (job #1591040) | Cod sursa (job #336145) | Cod sursa (job #2103853) | Cod sursa (job #1650697)
#include <iostream>
#include <cstdio>
#include <vector>
#define mod 666013
using namespace std;
int n,nr;
vector<int> h[mod+3];
inline vector<int>::iterator find_it(int val)
{
nr=val%mod;
vector<int>::iterator it;
for(it=h[nr].begin();it!=h[nr].end();it++) if(*it==val) return it;
return h[nr].end();
}
inline void ins(int val)
{
nr=val%mod;
vector<int>::iterator it=find_it(val);
if(it==h[nr].end()) h[nr].push_back(val);
}
inline void del(int val)
{
nr=val%mod;
vector<int>::iterator it=find_it(val);
if(it!=h[nr].end()) h[nr].erase(it);
}
int main()
{
int tip,val;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for(;n;n--)
{
scanf("%d%d",&tip,&val);
if(tip==1) ins(val);
if(tip==2) del(val);
if(tip==3)
{
vector<int>::iterator it=find_it(val);
if(it!=h[ val%mod ].end()) printf("1\n");
else printf("0\n");
}
}
fclose(stdin);
fclose(stdout);
return 0;
}