Cod sursa(job #2370678)

Utilizator qwerty1234qwerty qwerty1234 Data 6 martie 2019 13:05:00
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.13 kb

#include <bits/stdc++.h>


using namespace std;

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


const int P = 123457;

vector < int > L[P + 1];

int main()
{
    int x, op, n, r;
    bool ok;
    fin >> n;
    for(int i = 1 ; i <= n ; i++)
    {
        fin >> op >> x;
        if(op == 1)
        {
            ok = false;
            r = x % P;
            for(auto it : L[r])
                if(it == x)
                {
                    ok = true;
                    break;
                }
            if(!ok)
                L[r].push_back(x);
        }
        else if(op == 2)
        {
            r = x % P;
            for(unsigned int j = 0 ; j < L[r].size() ; j++)
                if(L[r][j] == x)
                    L[r].erase(L[r].begin() + j);
        }
        else
        {
            r = x % P;
            ok = false;
            for(auto it : L[r])
                if(it == x)
                {
                    ok = true;
                    break;
                }
            fout << ok << "\n";
        }
    }
    fin.close();
    fout.close();
}