Cod sursa(job #1788081)

Utilizator bciobanuBogdan Ciobanu bciobanu Data 25 octombrie 2016 17:20:09
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <bits/stdc++.h>

using namespace std;

int main() {
    ifstream cin("hashuri.in");
    ofstream cout("hashuri.out");
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    
    unordered_set<int> hash_set;

    srand(time(0));
    const int xor_const = (rand() << 15) ^ rand();

    for (int iter = 0; iter < n; iter += 1) {
        int op_type, el; cin >> op_type >> el; 
        el ^= xor_const;

        if (op_type == 1) {
            hash_set.insert(el);
        } else if (op_type == 2) {
            hash_set.erase(el);
        } else {
            cout << (hash_set.find(el) != hash_set.end()) << '\n';
        }
    }

    return 0;
}