Pagini recente » Cod sursa (job #342473) | Cod sursa (job #560899) | Cod sursa (job #342471) | Cod sursa (job #1383101) | Cod sursa (job #327197)
Cod sursa(job #327197)
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
int *list[1 << 20];
#define P (1000003)
int f(int x)
{
int m = x % P;
if (list[m])
for (int i = 1; i <= list[m][0]; ++i)
if (list[m][i] == x)
return 1;
return 0;
}
void a(int x)
{
int m = x % P;
if (!list[m])
{
list[m] = (int*) realloc(list[m], sizeof(int));
list[m][0] = 0;
}
if (!f(x))
{
list[m][0]++;
list[m] = (int*) realloc(list[m], sizeof(int)*(list[m][0]+1));
list[m][list[m][0]] = x;
}
}
void r(int x)
{
int m = x % P;
if (list[m])
for (int i = 1; i <= list[m][0]; ++i)
if (list[m][i] == x)
{
list[m][i] = 0;
return;
}
}
int main()
{
ifstream fi("hashuri.in");
ofstream fo("hashuri.out");
int N, op, x;
fi >> N;
while (N--)
{
fi >> op >> x;
if (op == 1)
a(x);
if (op == 2)
r(x);
if (op == 3)
fo << f(x) << '\n';
}
fi.close();
fo.close();
return 0;
}