Cod sursa(job #951447)

Utilizator a_h1926Heidelbacher Andrei a_h1926 Data 20 mai 2013 16:51:30
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include <cstdio>
#include <cassert>

#include <unordered_set>

using namespace std;

template<class IntType>
class IntHashCode {
  public:
    int operator()(const IntType &x) const {
        return x % U;
    }

  private:
    static const int U = 666013;
};

unordered_set<int, IntHashCode<int>> Hash;

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)
            Hash.insert(x);
        if (type == 2)
            Hash.erase(x);
        if (type == 3)
            printf("%d\n", Hash.find(x) != Hash.end());
    }
    return 0;
}