Cod sursa(job #2976303)

Utilizator biancalautaruBianca Lautaru biancalautaru Data 8 februarie 2023 22:08:56
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 kb
#include <fstream>
#include <algorithm>
#include <vector>
#define mod 999773
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n,op,x,h;
bool ok;
vector<int> f[mod];
vector<int>::iterator it;
int main() {
    fin>>n;
    while (n--) {
        fin>>op>>x;
        h=x%mod;
        it=find(f[h].begin(),f[h].end(),x);
        if (it!=f[h].end())
            ok=1;
        else
            ok=0;
        if (op==1 && ok==0)
            f[h].push_back(x);
        if (op==2 && ok==1)
            f[h].erase(it);
        if (op==3)
            fout<<ok<<"\n";
    }
    return 0;
}