Pagini recente » Cod sursa (job #2182870) | Cod sursa (job #3183825) | Cod sursa (job #2624266) | Cod sursa (job #1390423) | Cod sursa (job #1253133)
#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*modf(x*hash_value,(double*)&x);
return x%101;
}
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);
switch(x){
case 1:
if(it == lst[ind].end())
lst[ind].push_front(y);
break;
case 2:
if(it != lst[ind].end())
lst[ind].erase(it);
break;
case 3:
if(it != lst[ind].end())
printf("1\n");
else
printf("0\n");
}
}
}