Pagini recente » Cod sursa (job #2728429) | Cod sursa (job #9406) | Cod sursa (job #2534768) | Cod sursa (job #50684) | Cod sursa (job #1785012)
#include <bits/stdc++.h>
using namespace std;
const int mod = 480000000;
const int rand_n = 970005041;
int n, type, x;
bitset < mod + 10 > hash_;
int find_pos(int x)
{
x ^= rand_n;
x *= x;
x %= mod;
return x;
}
void update(int x, int v)
{
int pos = find_pos(x);
hash_[pos] = v;
}
int check(int x)
{
int pos = find_pos(x);
return hash_[pos];
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
for (scanf("%d", &n); n ; --n)
{
scanf("%d %d", &type, &x);
if (type <= 2)
update(x, type & 1);
if (type == 3)
printf("%d\n", check(x));
}
return 0;
}