Cod sursa(job #1702109)

Utilizator h2g2Ford Prefect h2g2 Data 14 mai 2016 15:36:00
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 1.04 kb
#include <bits/stdc++.h>
#define nmax 1000006
using namespace std;

int n, op, x;

vector <int> v;

int main() {
    ifstream cin("hashuri.in");
    ofstream cout("hashuri.out");
    cin>>n;
    for(int i=1; i<=n; i++) {
        cin>>op>>x;

        if(op == 1) {
            // trebuie adaugat
            bool gasit = false;
            for(int j=0; j<v.size(); j++)
                if(v[j] == x)
                    gasit = true;

            if(!gasit)
                v.push_back(x);
        }
        else if(op == 2) {
            // trebuie sters
            for(int j=0; j<v.size(); j++)
                if(v[j] == x) {
                    v[j] = v[v.size()-1];
                    v.pop_back();
                }
        }
        else {
            // trebuie raspuns la intrebare
            bool gasit = false;
            for(int j=0; j<v.size(); j++)
                if(v[j] == x)
                    gasit = true;

            if(gasit)
                cout<<"1\n";
            else
                cout<<"0\n";
        }
    }

    return 0;
}