Pagini recente » Cod sursa (job #1607968) | Cod sursa (job #529428) | Cod sursa (job #408560) | Cod sursa (job #2289710) | Cod sursa (job #780803)
Cod sursa(job #780803)
#include <cstdio>
#include <vector>
using namespace std;
const int U = 666013;
vector<int> H[U];
inline int Find(const int Value) {
int Key = Value%U;
for (vector<int>::iterator X = H[Key].begin(); X != H[Key].end(); ++X)
if (*X == Value)
return 1;
return 0;
}
inline void Insert(const int Value) {
int Key = Value%U;
if (!Find(Value))
H[Key].push_back(Value);
}
inline void Erase(const int Value) {
int Key = Value%U;
for (vector<int>::iterator X = H[Key].begin(); X != H[Key].end(); ++X) {
if (*X == Value) {
H[Key].erase(X);
return;
}
}
}
int main() {
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int N; scanf("%d", &N);
for (; N; --N) {
int Type, Value;
scanf("%d %d", &Type, &Value);
if (Type == 1)
Insert(Value);
if (Type == 2)
Erase(Value);
if (Type == 3)
printf("%d\n", Find(Value));
}
return 0;
}