Pagini recente » Cod sursa (job #262575) | Cod sursa (job #2859766) | Cod sursa (job #1664219) | Cod sursa (job #2069318) | Cod sursa (job #1784997)
#include <bits/stdc++.h>
using namespace std;
const int mod = (1 << 21) - 1;
const int rand_n = 970005041;
int n, type, x;
bool hash_[mod+10];
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;
}