Pagini recente » Cod sursa (job #1799998) | Cod sursa (job #1666207) | Cod sursa (job #771646) | Cod sursa (job #972466) | Cod sursa (job #2646985)
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
const int INF = 2e9;
class HashMap {
private:
const static int MOD = 666013;
vector <int> table[MOD];
public:
bool Find(int elem) {
int H = elem % MOD;
for(vector <int> :: iterator it = table[H].begin(); it != table[H].end(); it++) {
if(*it == elem)
return true;
}
return false;
}
void Insert(int elem) {
int H = elem % MOD;
if(!Find(elem))
table[H].push_back(elem);
}
void Erase(int elem) {
int H = elem % MOD;
for(vector <int> :: iterator it = table[H].begin(); it != table[H].end(); it++) {
if(*it == elem) {
table[H].erase(it);
return;
}
}
}
};
HashMap hm;
int main() {
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int n;
scanf("%d", &n);
while(n--) {
int t, x;
scanf("%d%d", &t, &x);
if(t == 1) hm.Insert(x);
else if(t == 2) hm.Erase(x);
else printf("%d\n", hm.Find(x));
}
return 0;
}