Cod sursa(job #2746938)

Utilizator carmenacatrineiCarmen-Lorena Acatrinei carmenacatrinei Data 28 aprilie 2021 18:13:12
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.42 kb
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <numeric>
#include <sstream>
#include <cmath>
#include <set>
#include <stack>
#include <iomanip>
#include <limits.h>
#include <queue>
#include <fstream>
#include <unordered_set>
#include <unordered_map>
#include <exception>
#include <deque>
#include <string>

using namespace std;
fstream in_file;
fstream out_file;

//#define BigPrime 786433;

int main()
{
    in_file.open("hashuri.in");
    out_file.open("hashuri.out", ios::out);

    set<int> hash;

    int n;
    in_file >> n;

    int operatie, val;

    while (n--)
    {
        in_file >> operatie;

        if (operatie == 1)
        {
            in_file >> val;
            val = val;// % BigPrime;
            if (hash.find(val) == hash.end())
                hash.insert(val);
        }
        else if (operatie == 2)
        {
            in_file >> val;
            val = val;//% BigPrime;
            if (hash.find(val) != hash.end())
                hash.erase(val);
        }
        else
        {
            in_file >> val;
            val = val;// % BigPrime;
            if (hash.find(val) != hash.end())
            {
                out_file << '1' << "\n";
            }
            else
            {
                out_file << '0' << "\n";
            }
        }
    }


    in_file.close();
    out_file.close();
}