Pagini recente » Cod sursa (job #1200440) | Cod sursa (job #1159682) | Cod sursa (job #949915) | Cod sursa (job #966859) | Cod sursa (job #1479145)
#include <cstdio>
using namespace std;
#define gc getchar
#define isdigit(c) (c>='0'&&c<='9')
char c;
void Read(int &a) {
for(c=gc(); !isdigit(c); c=gc());
for(a=0; isdigit(c); a=a*10+c-'0', c=gc());
}
#define P 8388608
#define B 37
struct HashMap {
int V[P];
void insert(int val) {
int pos = val % P;
while(V[pos]) {
if(V[pos] == val) return;
pos = pos * B % P;
}
V[pos] = val;
}
void erase(int val) {
int pos = val % P;
while(V[pos] != val) {
if(V[pos] == 0) return;
pos = pos * B % P;
}
V[pos] = -1;
}
bool find(int val) {
int pos = val % P;
while(V[pos]) {
if(V[pos] == val) return 1;
pos = pos * B % P;
}
return 0;
}
};
HashMap H;
int main() {
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int m, t, a;
Read(m);
while(m--) {
Read(t); Read(a);
if(t == 1) H.insert(a);
if(t == 2) H.erase(a);
if(t == 3) printf("%d\n", H.find(a));
}
return 0;
}