Cod sursa(job #2159472)

Utilizator savigunFeleaga Dragos-George savigun Data 10 martie 2018 22:49:32
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.93 kb
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;

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

const int BUFSIZE = 7000000;
int ptr;
char buff[BUFSIZE];

int n;
unordered_map<int, int> Map;

void read() {
    in.read(buff, BUFSIZE);
    ptr = 0;
}

int next_int() {
    int x = 0;
    while (!isdigit(buff[ptr])) ptr++;

    while (isdigit(buff[ptr])) {
        x = x * 10 + (buff[ptr] - '0');
        ptr++;
        if (ptr >= BUFSIZE) read();
    }

    return x;
}

int main()
{
    in.read(buff, BUFSIZE);
    n = next_int();

    for (int i = 1, o, x; i <= n; ++i) {
        o = next_int();
        x = next_int();
        if (o == 1) {
            Map[x] = 1;
        } else if (o == 2) {
            Map[x] = 0;
        } else if (o == 3) {
            if (Map[x]) out << 1; else out << 0;
            out << "\n";
        }
    }

    return 0;
}