Cod sursa(job #2739004)

Utilizator ionut31Ioan Ionescu ionut31 Data 6 aprilie 2021 17:43:07
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.88 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

const int N = 999983;

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

vector<int> v[N+5];


int main() {
    int n, x, op;
    fin >> n;
    for(int i=0; i<N; ++i)
        v[i] = vector<int>();
    for(int i=0; i<n; ++i)
    {
        fin >> op >> x;
        int y = x%N;
        int gasit = 0;
        vector<int>::iterator it;
        for (it = v[y].begin(); it != v[y].end(); ++it)
            if(*it == x)
            {
                gasit = 1;
                break;
            }
        if(op == 1 ) {
            if(gasit == 0)
                v[y].push_back(x);
        }
        else if(op == 2)
        {
            if(gasit == 1)
            {
               v[y].erase(it);
            }
        }
        else
        {
            fout << gasit << "\n";
        }
    }

    return 0;
}