Cod sursa(job #2378769)

Utilizator KemyKoTeo Virghi KemyKo Data 12 martie 2019 16:49:31
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <fstream>
#include <set>
#define MOD 666013

using namespace std;

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

multiset <int> v[MOD];
multiset <int>::iterator it;

int n, i, op, x, pos;

int main()
{
    f >> n;
    for(i=1; i<=n; i++){
        f >> op >> x;

        pos = x % 666013;
        it = v[pos].lower_bound(x);
        if(op==1 && (*it) != x)
            v[pos].insert(x);
        if(op==2 && (*it) == x)
            v[pos].erase(x);
        if(op==3){
            if( (*it) == x) g << "1\n";
            else g << "0\n";
        }

    }
    return 0;
}