Cod sursa(job #2625043)

Utilizator tudosemihaitudose mihai tudosemihai Data 5 iunie 2020 18:04:28
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.91 kb
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>

#define P 35281

using namespace std;

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

vector<int> v[P];

int main()
{
    int n;
    in >> n;

    for(int i = 0; i < n ; i++ )
    {
        int op, x;
        in >> op >> x;
        if( op==1 ){
            int h = x % P;
            auto it = find(v[h].begin(), v[h].end(), x);
            if (it == v[h].end())
                v[h].push_back(x);
        }
        else if( op==2 ){
            int h = x % P;
            auto it = find(v[h].begin(), v[h].end(), x);
            if (it != v[h].end())
                v[h].erase(it);
        } else if( op==3 ){
            int h = x % P;
            auto it = find(v[h].begin(), v[h].end(), x);
            if (it != v[h].end())
                out << "1\n";
            else
                out << "0\n";
        }
    }

	return 0;
}