Cod sursa(job #2740610)

Utilizator TUdOr73Minciunescu Tudor TUdOr73 Data 13 aprilie 2021 17:17:57
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.95 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;
const int prim = 666013;

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

vector<int> v[prim+4];


int main()
{
    int n,cod,x;
    f >> n;
    for(int i = 0; i< prim; i++)
        v[i] = vector<int>();
    for(int i = 0; i< n; i++) {
        f >> cod >> x;
        int key = x % prim;
        bool ok = 0;
        vector<int>::iterator poz;
        for (auto j = v[key].begin(); j < v[key].end(); j++) {
            if (*j == x){
                ok = 1;
                poz = j;
                break;
            }
        }
        if ( cod == 1){
            if( ok == 0)
                v[key].push_back(x);
        }
        else if (cod == 2){
            if ( ok == 1)
                v[key].erase(poz);
        }
        else if (cod == 3){
            if (ok == 1 )
                g << 1 << '\n';
            else
                g << 0 << '\n';
        }
    }


    return 0;
}