Cod sursa(job #2894467)

Utilizator Alexandru_PotangaPotanga Alexandru Alin Alexandru_Potanga Data 27 aprilie 2022 20:59:21
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.13 kb
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int> v[666013];
int main()
{
    int n, tip, x, y, i, j;
    bool ok;
    f >> n;
    for(i = 0; i < n; i++)
    {
        f >> tip >> x;
        y = x % 666013;
        if(tip == 1)
        {
            ok = true;
            for(j = 0; j < v[y].size() && ok == true; j++)
                if(x == v[y][j])
                    ok = false;
            if(ok == true)
                v[y].push_back(x);
        }
        else
        if(tip == 2)
        {
            ok = true;
            for(j = 0; j < v[y].size() && ok == true; j++)
                if(x == v[y][j])
                    ok = false;
            if(ok == false)
                v[y].erase(v[y].begin() + j - 1);
        }
        else
        {
            ok = true;
            for(j = 0; j < v[y].size() && ok == true; j++)
                if(x == v[y][j])
                    ok = false;
            if(ok == false)
                g << 1 << "\n";
            else g << 0 << "\n";
        }
    }
    return 0;
}