Pagini recente » Cod sursa (job #1598975) | Cod sursa (job #2660928) | Cod sursa (job #1770521) | Cod sursa (job #122680) | Cod sursa (job #1587525)
#include<fstream>
#define infile "hashuri.in"
#define outfile "hashuri.out"
#define MAX 1000005
using namespace std;
ifstream fin(infile);
ofstream fout(outfile);
typedef struct nod {
int inf;
nod* next;
}*lista;
int n, op, x;
lista h[MAX];
bool ok(int y)
{
for (lista j = h[y % MAX]; j!=NULL; j = j->next)
if (j->inf == y) return 1;
return 0;
}
void add(lista &a, int inf)
{
lista q = new nod;
q->inf = inf;
q->next = a;
a = q;
}
int main()
{
fin >> n;
for (int i = 0; i < n; i++)
{
fin >> op >> x;
if (op == 1)
{
if (ok(x) == 0)
add(h[x % MAX], x);
}
if (op == 2)
{
if (ok(x) == 1)
for (lista j = h[x % MAX]; j != NULL; j = j->next)
if (j->inf == x)
{
j->inf = -1;
}
}
if (op == 3) {
fout << ok(x) << endl;
}
}
return 0;
}