Pagini recente » Cod sursa (job #2936479) | Cod sursa (job #355924) | Cod sursa (job #182877) | Cod sursa (job #2431625) | Cod sursa (job #616549)
Cod sursa(job #616549)
#include<stdio.h>
#include<stdlib.h>
#define PRIM 999979
//999979
long i, j, n, LgVec[PRIM + 1], x, y, ok;
long * vec[PRIM + 1];
long yy;
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)
{
if (vec[yy] == NULL)
vec[yy] = (long *) malloc(sizeof(long));
else
vec[yy] = (long *) realloc(vec[yy], sizeof(long) * (LgVec[yy] + 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;
}