Pagini recente » Cod sursa (job #2422925) | Cod sursa (job #1636231) | Cod sursa (job #102582) | Cod sursa (job #777075) | Cod sursa (job #1775222)
#include <cstdio>
#define in "hashuri.in"
#define out "hashuri.out"
#define MOD 666013
using namespace std;
int n, op, val, hashTable[MOD];
void addHash(const int &value)
{
int key = value%MOD;
while(hashTable[key])
{
if(hashTable[key] == value) return ;
++key;
if(key == MOD) key = 0;
}
hashTable[key] = value;
}
void removeHash(const int &value)
{
int key = value%MOD;
while(hashTable[key])
{
if(hashTable[key] == value)
{
hashTable[key] = 0;
return ;
}
++key;
if(key == MOD) key = 0;
}
}
int checkHash(const int &value)
{
int key = value%MOD;
while(hashTable[key])
{
if(hashTable[key] == value) return 1;
++key;
if(key == MOD) key = 0;
}
return 0;
}
int main()
{
freopen(in, "r", stdin);
freopen(out, "w", stdout);
scanf("%d", &n);
for(int i = 1; i<= n; ++i)
{
scanf("%d %d", &op, &val);
if(op == 1) addHash(val);
if(op == 2) removeHash(val);
if(op == 3) printf("%d\n", checkHash(val));
}
}