Pagini recente » Cod sursa (job #3261718) | Cod sursa (job #1792036) | Cod sursa (job #2650914) | Cod sursa (job #742343) | Cod sursa (job #316070)
Cod sursa(job #316070)
#include<cstdio>
#include<vector>
#define DIV 9001
#define MOD 666013
#define MAXN 1 << 20
using namespace std;
inline int Hash( int x) {
return ( ((x / DIV) + 1) << 5) % MOD;
}
int i , j , N , type , ok , arg;
vector <int> H[MOD];
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d ",&N);
for( ; N -- ; )
{
scanf("%d %d",&type, &arg);
if( type == 1)
H[Hash(arg)].push_back(arg);
else if(type == 2)
{
for( j = 0 ; j < H[Hash(arg)].size() ;j++)
if( H[Hash(arg)][j] == arg ) H[Hash(arg)][j] = - 1;
}
else if(type == 3)
{
ok = 0;
for( j = 0 ; j < H[Hash(arg)].size();j++)
if(H[Hash(arg)][j] == arg) ok = 1;
printf("%d\n",ok);
}
}
return 0;
}