Cod sursa(job #1952577)

Utilizator jurjstyleJurj Andrei jurjstyle Data 4 aprilie 2017 11:12:36
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.86 kb
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

ifstream f("hashuri.in");
ofstream g("hashuri.out");

const int mod = 777013;
vector <int> G[mod + 1];
int N;

void inserare(int x)
{
    int ind = x % mod;
    if (find(G[ind].begin(), G[ind].end(), x) == G[ind].end())
        G[ind].push_back(x);
}
void stergere(int x)
{
    int ind = x % mod;
    vector <int> :: iterator it = find(G[ind].begin(), G[ind].end(), x);
    if (it != G[ind].end())
        G[ind].erase(it);
}


int main()
{
    f >> N;
    for (; N--;)
    {
        int op, x;
        f >> op >> x;
        if (op == 1)
            inserare(x);
        else if (op == 2)
            stergere(x);
        else
            g << (find(G[x % mod].begin(), G[x % mod].end(), x) != G[x % mod].end()) << "\n";
    }
    f.close();
    g.close();
}