Cod sursa(job #2622864)

Utilizator florian_petrutCoaje Petrut florian_petrut Data 1 iunie 2020 23:29:56
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.97 kb
#include <iostream>

#include <fstream>

#include <vector>

using namespace std;

vector<int> hasht[66013];



void Add(int x){

    hasht[x % 66013].push_back(x);

}



void Delete(int x){

    int m = x % 66013;

    for (int i = 0; i < hasht[m].size(); i++)

        if(hasht[m][i] == x)

            hasht[m].erase(hasht[m].begin()+i);



}



int Search(int x){

    int m = x % 66013;

    for (int i = 0; i < hasht[m].size(); i++)

        if(hasht[m][i] == x)

            return 1;





    return 0;

}





int main()

{

    ifstream f("hashuri.in");

    ofstream g("hashuri.out");



    int n, x, y;

    f>>n;

    for(; n; n--){

        f >> x >> y;

        if(x == 1)

           Add(y);

        else

            if(x == 2)

                Delete(y);

            else

                g << Search(y) << '\n';



        }

    f.close();

    g.close();

    return 0;

}