Pagini recente » Cod sursa (job #2158468) | Cod sursa (job #297953) | Cod sursa (job #186364) | Cod sursa (job #1552206) | Cod sursa (job #616545)
Cod sursa(job #616545)
#include<stdio.h>
#include<stdlib.h>
#define PRIM 1000000
//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;
}
long yy;
for(i = 1; i <= n; i++)
{
scanf("%ld %ld", &x, &y);
yy = y % PRIM;
if(x == 1)
{
vec[yy][LgVec[yy]] = y;
LgVec[yy]++;
}
if(x == 2)
{
for(j = 0; j < LgVec[yy]; j++)
if(vec[yy][j] == y)
vec[yy][j] = -1;
}
if(x == 3)
{
ok = 1;
for(j = 0; j < LgVec[yy] && ok == 1; j++)
if(vec[yy][j] == y)
{
printf("1\n");
ok = 0;
}
if(ok == 1)
printf("0\n");
}
}
fclose(stdout);
return 0;
}