Pagini recente » Cod sursa (job #2231679) | Cod sursa (job #573352) | Cod sursa (job #1883563) | Cod sursa (job #2739970) | Cod sursa (job #616542)
Cod sursa(job #616542)
#include<stdio.h>
#include<stdlib.h>
#define PRIM 999979
long i, j, n, LgVec[PRIM + 1], x, y, ok;
long * vec[PRIM + 1];
int main()
{
freopen("hashuri.in", "rt", stdin);
freopen("hashuri.out", "wt", stdout);
scanf("%ld", &n);
for(i = 1; i <= n; i++)
{
scanf("%ld %ld", &x, &y);
if(x == 1)
LgVec[y % PRIM]++;
}
freopen("hashuri.in", "rt", stdin);
scanf("%ld", &n);
for(i = 0; i < PRIM; i++)
if(LgVec[i] != 0)
{
vec[i] = (long*) malloc(LgVec[i] * sizeof(long));
LgVec[i] = 0;
}
for(i = 1; i <= n; i++)
{
scanf("%ld %ld", &x, &y);
if(x == 1)
{
vec[y % PRIM][LgVec[y % PRIM]] = y;
LgVec[y % PRIM]++;
}
if(x == 2)
{
for(j = 0; j < LgVec[y % PRIM]; j++)
if(vec[y % PRIM][j] == y)
vec[y % PRIM][j] = -1;
}
if(x == 3)
{
ok = 1;
for(j = 0; j < LgVec[y % PRIM] && ok == 1; j++)
if(vec[y % PRIM][j] == y)
{
printf("1\n");
ok = 0;
}
if(ok == 1)
printf("0\n");
}
}
fclose(stdout);
return 0;
}