Cod sursa(job #3291573)

Utilizator brianabucur11Briana Bucur brianabucur11 Data 5 aprilie 2025 09:53:58
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda cex_9 Marime 0.9 kb
#include <bits/stdc++.h>

using namespace std;

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

const int mod=666013;

vector <int> h[mod];
int n, ind;
vector<int>::iterator it;

vector<int>::iterator find (int x)
{
    for (it=h[ind].begin(); it!=h[ind].end(); it++)
    {
        if (*it==x)
        return it;
    }
    return h[ind].end();
}

void add (int x)
{
    if (it==h[ind].end())
        h[ind].push_back(x);
}

void del (int x)
{
    if (it!=h[ind].end())
        h[ind].erase(it);
}

void afis (int x)
{
    fout << (it!=h[ind].end()) << '\n';
}

int main()
{
    fin >> n;
    for (int i=1; i<=n; i++)
    {
        int cer, x;
        fin >> cer >> x;
        ind=x%mod;
        it=find(x);
        if (cer==1)
            add(x);
        if (cer==2)
            del(x);
        if (cer==3)
            afis(x);
    }
    return 0