Cod sursa(job #3229012)

Utilizator ChopinFLazar Alexandru ChopinF Data 12 mai 2024 22:27:26
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.94 kb
#include <bits/stdc++.h>

using namespace std;
std::ifstream fin("hashuri.in");
std::ofstream fout("hashuri.out");
const int p = 1e6 + 7;
std::vector<int>v[p];
int q;
int main()
{
    fin >> q;
    for(int t =  0 ; t < q ; ++t)
    {
        int op , x , cx;
        fin >> op >> x;
        cx = x;
        x = x % p;
        if(op == 1)
        {
            v[x].push_back(cx);
        }
        else if(op == 2)
        {
            vector<int>aux;
            for(const auto & el : v[x])
            {
                if(el != cx)
                {
                    aux.push_back(el);
                }
            }
            v[x] = aux;
        }
        else
        {
            bool ok = false;
            for(const auto & el : v[x])
            {
                if(el == cx)
                {
                    ok = true;
                }
            }
            if(ok == true)fout << "1\n";
            else fout << "0\n";
        }
    }
}