Pagini recente » Cod sursa (job #2900809) | Cod sursa (job #476899) | Cod sursa (job #532406) | Monitorul de evaluare | Cod sursa (job #903064)
Cod sursa(job #903064)
#include <cstdio>
#include <cstring>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;
typedef vector<int>::iterator it;
const int oo = 0x3f3f3f3f;
const int U = 666013;
vector<int> H[U];
inline int Search(int X) {
int Key = X % U;
for (it Y = H[Key].begin(); Y != H[Key].end(); ++Y)
if (*Y == X)
return 1;
return 0;
}
inline void Insert(int X) {
int Key = X % U;
if (!Search(X))
H[Key].push_back(X);
}
inline void Erase(int X) {
int Key = X % U;
for (it Y = H[Key].begin(); Y != H[Key].end(); ++Y) {
if (*Y == X) {
H[Key].erase(Y);
return;
}
}
}
int main() {
assert(freopen("hashuri.in", "r", stdin));
assert(freopen("hashuri.out", "w", stdout));
int N; assert(scanf("%d", &N) == 1);
for (; N > 0; --N) {
int Type, X; assert(scanf("%d %d", &Type, &X) == 2);
if (Type == 1)
Insert(X);
if (Type == 2)
Erase(X);
if (Type == 3)
printf("%d\n", Search(X));
}
return 0;
}