Cod sursa(job #2548642)

Utilizator Horia14Horia Banciu Horia14 Data 16 februarie 2020 20:56:10
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.13 kb
#include<fstream>
#include<iostream>
#include<unordered_map>
#include<cctype>
#define BUF_SIZE 1 << 18
using namespace std;

unordered_map<int, int> umap;
int pos = BUF_SIZE;
char buf[BUF_SIZE];

/*inline char getChar(FILE *fin) {
    if(pos == BUF_SIZE) {
        fread(buf, 1, BUF_SIZE, fin);
        pos = 0;
    }
    return buf[pos++];
}

inline int read(FILE* fin) {
    int res = 0;
    char ch;
    do {
        ch = getChar(fin);
    }while(!isdigit(ch));
    do {
        res = 10*res + ch - '0';
        ch = getChar(fin);
    }while(isdigit(ch));
    return res;
}*/

int main() {
    int n, op, x;
    FILE* fin, *fout;
    fin = fopen("hashuri.in", "r");
    fout = fopen("hashuri.out", "w");
    //n = read(fin);
    fscanf(fin,"%d",&n);
    for(int i = 1; i <= n; i++) {
        /*op = read(fin);
        x = read(fin);*/
        fscanf(fin,"%d%d",&op,&x);
        if(op == 1)
            umap[x] = 1;
        else if(op == 2) {
            umap[x] = 0;
        } else {
            if(umap[x])
                fprintf(fout,"1\n");
            else fprintf(fout,"0\n");
        }
    }
    fclose(fin);
    fclose(fout);
    return 0;
}