Pagini recente » Cod sursa (job #447064) | Cod sursa (job #2155506) | Cod sursa (job #2924058) | Cod sursa (job #3237667) | Cod sursa (job #1098725)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
struct Hash {
int elem;
Hash *next;
};
const int key = 100005;
Hash *H[key];
void add(const int &V) {
Hash *D = new Hash;
D->elem = V;
D->next = H[V % key];
H[V % key] = D;
}
void del(const int &V) {
for (Hash *X = H[V % key]; X != NULL; X = X->next)
if (X->elem == V) {
X->elem = 0;
return ;
}
}
int ask(const int &V) {
for (Hash *X = H[V % key]; X != NULL; X = X->next)
if (X->elem == V)
return 1;
return 0;
}
int main() {
int N;
for (fin >> N; N--; ) {
int Q, V;
fin >> Q >> V;
if (Q == 1)
add(V);
else if (Q == 2)
del(V);
else
fout << ask(V) << '\n';
}
fin.close();
fout.close();
}