Pagini recente » Cod sursa (job #917841) | Cod sursa (job #1042325) | Cod sursa (job #224589) | Cod sursa (job #2796240) | Cod sursa (job #1253152)
#include <cstdio>
#include <list>
#define ll long long
using namespace std;
ll n;
list < ll > lst[65535];
list <ll> :: iterator it;
inline ll hash_u(ll x){
return x%65535;
}
list <ll> :: iterator search_u(ll x){
ll ind;
ind = hash_u(x);
for( 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;
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");
}
}