Cod sursa(job #2221328)

Utilizator andreisontea01Andrei Sontea andreisontea01 Data 13 iulie 2018 19:13:37
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.9 kb
#include <fstream>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

map<int, vector<int> > sir;

int main()
{
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");
    int n;
    fin >> n;
    int op, x, theta = 403301;
    for(int i = 1; i <= n; ++i){
        fin >> op >> x;
        if(op == 1)
            sir[x % theta].push_back(x);
        if(op == 2){
            for(int i = 0; i < sir[x % theta].size(); ++i){
                if(sir[x % theta][i] == x){
                    sir[x % theta].erase(sir[x % theta].begin() + i);
                    break;
                }
            }
        }
        if(op == 3){
            bool exista = 0;
            for(int i = 0; i < sir[x % theta].size() && !exista; ++i){
                if(sir[x % theta][i] == x)
                    exista = 1;
            }
            fout << exista << "\n";
        }
    }
    return 0;
}