Cod sursa(job #3291579)

Utilizator Luca_georgescuLucageorgescu Luca_georgescu Data 5 aprilie 2025 09:55:41
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda cex_9 Marime 0.78 kb
include <bits/stdc++.h>

using namespace std;

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

const int mod=666013;
vector <int> h[mod];

int n,r;

bool findx (int x)
{
    for (auto a:h[r] )
        if ( a==x )
           return true;

    return false;
}

void insertx (int x)
{
    h[r].push_back(x);
}

void erasex (int x)
{
    vector <int> cpy;

    for (auto a:h[r] )
        if ( a!=x )
           cpy.push_back(a);

    h[r]=cpy;
}


int main()
{
    f >> n;

    for (int i=1; i<=n; i++ )
    {
        int c,x;
        f >> c >> x;

        r=x%mod;

        if ( c==1 )
            insertx(x);

        if ( c==2 )
            erasex(x);

        if ( c==3 )
            g << findx(x) << '\n';
    }

    return 0;
}