Cod sursa(job #730040)

Utilizator ColcerPColcer Paul ColcerP Data 2 aprilie 2012 02:25:43
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.86 kb
#include <fstream>
#include <vector>
using namespace std;

int n;
vector <int> M;
vector <int>::iterator it;

vector<int>::iterator findValue(int x){
    for(it = M.begin(); it != M.end(); it++)
        if(*it == x)
            return it;
    return M.end();
}

void insert(int x){
    if(findValue(x) == M.end())
        M.push_back(x);
}

void erase(int x){
    it = findValue(x);
    if (it != M.end())
        G.erase(it);
}

int main(){
    int tipOp,x;
    ifstream f("hashuri.in");
    ofstream g("hashuri.out");
    f>>n;
    for(int i = 1; i <= n; i++){
        f>>tipOp>>x;
        if(tipOp == 1){
            insert(x);
            continue;
        }
        if(tipOp == 2){
            erase(x);
            continue;
        }
        g<<(findValue(x)!= M.end());
    }

    f.close();
    g.close();
    return 0;
}