Cod sursa(job #3357816)

Utilizator TestLicenta123Test Test TestLicenta123 Data 13 iunie 2026 15:13:48
Problema Hashuri Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <fstream>
#include <vector>
#include <unordered_set>

using namespace std;

ifstream cin("hashuri.in");
ofstream cout("hashuri.out");

const int MOD = 1000133;

unordered_set<int> h[1001000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int tip, nr;
        cin >> tip >> nr;
        int pos = nr % MOD;

        if (tip == 1) {
            h[pos].insert(nr);
        } else if (tip == 2) {
            h[pos].erase(nr);
        } else if (tip == 3) {
            cout << (h[pos].count(nr) ? "1\n" : "0\n");
        }
    }

    return 0;
}