Cod sursa(job #2474400)

Utilizator CiboAndreiAndrei Cibo CiboAndrei Data 15 octombrie 2019 10:24:43
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.84 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("hashuri.in");
ofstream g("hashuri.out");
//ifstream f("date.in");
//ofstream g("date.out");

const int dim = 666013;

vector <int> v[dim];

int n, op, x;

int main()
{
    int i, rest, poz, j;
    bool exista;

    f >> n;

    for(i = 1; i <= n; ++i){
        f >> op >> x;
        exista = 0;

        rest = x % dim;

        for(j = 0; j < v[rest].size(); ++j){
            if(v[rest].at(j) == x){
                exista = 1;
                poz = j;
                break;
            }
        }

        if(op == 1 && !exista){
            v[rest].push_back(x);
        } else if(op == 2 && exista){
            v[rest].erase(v[rest].begin() + poz);
        } else if(op == 3){
            g << exista << '\n';
        }
    }

    return 0;
}