Pagini recente » Cod sursa (job #1864386) | Cod sursa (job #1289528) | Cod sursa (job #2283968) | Cod sursa (job #2490939) | Cod sursa (job #1638224)
#include <iostream>
#include <cstdio>
#include <vector>
#define mod 666013
using namespace std;
int n;
vector<int> h[mod+3];
inline vector<int>::iterator find_it(int val)
{
int poz=val%mod;
for(vector<int>::iterator it=h[poz].begin();it<h[poz].end();it++) if(*it==val) return it;
return h[poz].end();
}
inline void ins(int val)
{
int poz=val%mod;
vector<int>::iterator it=find_it(val);
if(it==h[poz].end()) h[poz].push_back(val);
}
inline void del(int val)
{
int poz=val%mod;
vector<int>::iterator it=find_it(val);
if(it!=h[poz].end()) h[poz].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;
}