Cod sursa(job #3233207)

Utilizator MirceaDonciuLicentaLicenta Mircea Donciu MirceaDonciuLicenta Data 2 iunie 2024 19:36:23
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.73 kb
#include <iostream>
#include <fstream>
#include <unordered_set>

using namespace std;

int main() {
    ifstream infile("hashuri.in");
    ofstream outfile("hashuri.out");

    if (!infile || !outfile) {
        cerr << "Error opening file" << endl;
        return 1;
    }

    int N;
    infile >> N;

    unordered_set<int> hashset;
    int op, x;

    for (int i = 0; i < N; ++i) {
        infile >> op >> x;
        if (op == 1) {
            hashset.insert(x);
        } else if (op == 2) {
            hashset.erase(x);
        } else if (op == 3) {
            outfile << (hashset.find(x) != hashset.end() ? 1 : 0) << endl;
        }
    }

    infile.close();
    outfile.close();

    return 0;
}