Cod sursa(job #2060538)

Utilizator leraValeria lera Data 8 noiembrie 2017 13:37:55
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.88 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n, op, x;
const int P = 10000007;
vector<int>V[P + 1];

int main()
{
    fin >> n;
    for(int i = 1; i <= n; i++)
    {
        fin >>  op >> x;
        if(op == 1)
        {
            V[x % P].push_back(x);
        }
        else if(op == 2)
        {
            int ok =-1;
            for(int j = 0; j < V[x % P].size(); j++)
                if(V[x % P][j] == x)ok = j;
            if(ok != -1)
                V[x % P].erase(V[x % P].begin() + ok);
        }
        else
        {
            int ok =-1;
            for(int j = 0; j < V[x % P].size(); j++)
                if(V[x % P][j] == x)ok = j;
            if(ok == -1)fout << 0 << '\n';
            else fout << 1 << '\n';
        }
    }
    return 0;
}