Cod sursa(job #2223937)

Utilizator vladm98Munteanu Vlad vladm98 Data 22 iulie 2018 12:22:54
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.84 kb
#include <bits/stdc++.h>

using namespace std;

set<int> hashh [1000000];

void insertt (int x) {
    int modulo = x % 1000000;
    hashh[modulo].insert(x);
}

void erasee (int x) {
    int modulo = x % 1000000;
    hashh[modulo].erase(x);
}

bool isIn (int x) {
    int modulo = x % 1000000;
    return hashh[modulo].find(x) != hashh[modulo].end();
}

int main() {
    ifstream fin ("hashuri.in");
    freopen("hashuri.out", "w", stdout);
    int n;
    fin >> n;
    for (int i = 1; i <= n; ++i) {
        int tip, x;
        fin >> tip >> x;
        if (tip == 1) {
            insertt(x);
        }
        if (tip == 2) {
            erasee(x);
        }
        if (tip == 3) {
            if (isIn(x)) {
                putchar('1');
            } else {
                putchar('0');
            }
            putchar('\n');
        }
    }
    return 0;
}