Pagini recente » Cod sursa (job #2735118) | Cod sursa (job #685693) | Cod sursa (job #120115) | Cod sursa (job #2919649) | Cod sursa (job #1253146)
#include <cstdio>
#include <list>
#define n_max 1000010
#define ll long long
//#define hash_value 0.618034
//#include <math.h>
using namespace std;
ll n;
list < ll > lst[n_max];
inline ll hash_u(ll x){
//return n*(double)(hash_value*x);
return x%65535;
}
list <ll> :: iterator search_u(ll x){
ll ind;
ind = hash_u(x);
for(list <ll> :: iterator it = lst[ind].begin() ; it != lst[ind].end() ; ++it ){
if((*it) == x){
return it;
}
}
return lst[ind].end();
}
int main(void)
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
ll y,ind;
int x;
list < ll > :: iterator it;
scanf("%lld ",&n );
while(n--){
scanf("%d %lld ",&x ,&y );
ind = hash_u(y);
it = search_u(y);
if(x==1){
if(it == lst[ind].end())
lst[ind].push_back(y);
continue;
}
if(x==2){
if(it != lst[ind].end())
lst[ind].erase(it);
continue;
}
if(it == lst[ind].end())
printf("0\n");
else
printf("1\n");
}
}