Cod sursa(job #1503180)

Utilizator mlupseLupse-Turpan Mircea mlupse Data 15 octombrie 2015 17:58:42
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.68 kb
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;

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

const int MOD = 666013;
vector <int> V[MOD];
int N;

int main()
{
    fin>>N;
    while(N--)
    {
        int op,x;

        fin>>op>>x;

        int List = x%MOD;
        vector <int> :: iterator it = find(V[List].begin(),V[List].end(),x);


        if(op == 1)
            if(it == V[List].end())
                V[List].push_back(x);
        if(op == 2)
            if(it != V[List].end())
                V[List].erase(it);
        if(op == 3)
            fout << (it != V[List].end())<<"\n";
    }
    return 0;
}