Cod sursa(job #2090994)

Utilizator osiaccrCristian Osiac osiaccr Data 18 decembrie 2017 22:50:56
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.13 kb
#include <fstream>
#include <vector>
#define MODO 699919

using namespace std;

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

vector < int > V[MODO];
vector < int > :: iterator it;

int n, t, i, x;

int main () {
    fin >> n;
    for (; n --;) {
        fin >> t >> x;
        i = x % MODO;
        if (t == 1) {
            for (it = V[i].begin (); it != V[i].end (); ++ it) {
                if (* it == x)
                    break;
            }
            if (it == V[i].end ())
                V[i].push_back (x);
        }
        if (t == 2) {
            for (it = V[i].begin (); it != V[i].end (); ++ it) {
                if (* it == x)
                    break;
            }
            if (it != V[i].end ()) {
                V[i].erase (it);
            }
        }
        if (t == 3) {
            for (it = V[i].begin (); it != V[i].end (); ++ it) {
                if (* it == x)
                    break;
            }
            if (it != V[i].end ())
                fout << 1 << "\n";
            else
                fout << 0 << "\n";
        }
    }
    return 0;
}