Cod sursa(job #3358000)

Utilizator TestLicenta123Test Test TestLicenta123 Data 13 iunie 2026 22:48:07
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.02 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <utility>

using namespace std;

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

const int NMAX = 2000000000;
const int PRIM = 1000003;

list<int> h[PRIM];

int main()
{
    int n;
    fin >> n;

    for(int i = 1; i <= n; i++)
    {
        int op, x;
        fin >> op >> x;

        int val = x % PRIM;

        if(op == 1)
        {
            bool ok = 0;
            for(const auto& elem : h[val])
                if(elem == x)
                {
                    ok = 1;
                    break;
                }

            if(!ok)
                h[val].push_back(x);
        }
        else if(op == 2)
        {
            h[val].remove(x);
        }
        else
        {
            int rez = 0;
            for(const auto& elem : h[val])
                if(elem == x)
                {
                    rez = 1;
                    break;
                }

            fout << rez << '\n';
        }
    }

    return 0;
}