Cod sursa(job #3131179)

Utilizator Cipy34Harnagea Ciprian Cipy34 Data 19 mai 2023 14:17:16
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.91 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

vector<int> hashuri[666013];
int main(){
    //ifstream fin("nr.txt");
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");
    int op, x, nr, ok;

    fin>>nr;

    for(int i = 0; i < nr; i++){
        fin>>op>>x;
        int prim = x%666013;
        int a = hashuri[prim].size();

        ok = 0;
        for(int j = 0; j < a; j++)
            if(hashuri[prim][j] == x)
                ok = 1;

        if(ok == 0 && op == 1){
            hashuri[prim].push_back(x);
        }
        else if(op == 2 && ok == 1){
                for(int j = 0; j < a; j++)
                    if(hashuri[prim][j] == x)
                        hashuri[prim].erase(hashuri[prim].begin()+j);
            }
        else if(op == 3)
            fout<<ok<<"\n";
    }
    fin.close();
    fout.close();
    return 0;
}