Cod sursa(job #3339067)

Utilizator filipdanieloanFilip-Daniel Oancea filipdanieloan Data 5 februarie 2026 22:41:00
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.71 kb
#include <bits/stdc++.h>
using namespace std;

unordered_map<int, bool> h;

void add(int x) {
    h[x] = true;
}

void remove(int x) {
    auto it = h.find(x);
    if(it != h.end())
        h.erase(it);
}

void query(int x) {
    auto it = h.find(x);
    if(it != h.end())
        cout << "1\n";
    else
        cout << "0\n";
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
#ifndef LOCAL
    freopen("hashuri.in", "r", stdin);
    freopen("hashuri.out", "w", stdout);
#endif

    int n; cin >> n;
    for(int i = 0; i < n; ++i) {
        int op, x; cin >> op >> x;
        if(op == 1)
            add(x);
        else if(op == 2)
            remove(x);
        else
            query(x);
    }

    return 0;
}