Cod sursa(job #3132051)

Utilizator LazarDanielGabrielLazar Daniel-Gabriel LazarDanielGabriel Data 21 mai 2023 22:58:28
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include <iostream>
#include <fstream>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");

    int n, x, y;
    const int MOD = 666041;
    vector<unordered_set<int>> valori(MOD);

    fin >> n;
    while (n--) {
        fin >> x >> y;
        int aux = y % MOD;

        if (x == 1) {
            valori[aux].insert(y);
        } else if (x == 2) {
            valori[aux].erase(y);
        } else if (x == 3) {
            bool rez = (valori[aux].count(y) != 0);
            fout << rez << '\n';
        }
    }

    fin.close();
    fout.close();
    return 0;
}