Cod sursa(job #1476447)
Utilizator | Data | 25 august 2015 10:20:22 | |
---|---|---|---|
Problema | Hashuri | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.6 kb |
#include <cstdio>
#include <unordered_set>
using namespace std;
const int TRESHOLD = 500;
int n;
unordered_set<int> H;
void solve() {
scanf("%d", &n);
H.reserve(n / 2 + TRESHOLD);
int type, x;
for (int i = 1; i <= n; i++) {
scanf("%d%d", &type, &x);
switch (type) {
case 1: {
H.insert(x);
break;
}
case 2: {
H.erase(x);
break;
}
case 3: {
printf("%d\n", (int)H.count(x));
break;
}
}
}
}
int main() {
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
solve();
return 0;
}