Cod sursa(job #1795795)

Utilizator mihai.alphamihai craciun mihai.alpha Data 2 noiembrie 2016 20:59:26
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.95 kb
#include <bits/stdc++.h>

using namespace std;
#define BUF_SIZE 1<<17
char buf[BUF_SIZE];
int pos = BUF_SIZE;
FILE *fin, *fout;
inline char nextch(){
    if(pos==BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos=0;
    return buf[pos++];
}

inline int read(){
    int x=0;
    char ch=nextch();
    while(!isdigit(ch)) ch=nextch();
    while(isdigit(ch)){
        x=10*x+ch-'0';
        ch=nextch();
    }
    return x;
}
unordered_map<int,int>hash1;
void desch()  {
    fin = fopen("hashuri.in", "r");
    fout = fopen("hashuri.out", "w");
}
void inch()  {
    fclose(fin);
    fclose(fout);
}
int main()  {
    desch();
    int n;
    n = read();
    int i;
    for(i = 0;i < n;i++)  {
        int op, x;
        op = read();
        x = read();
        if(op == 1)  {
            hash1[x] = 1;
        }
        if(op == 2)  {
            hash1[x] = 0;
        }
        if(op == 3)  {
            fprintf(fout, "%d\n", hash1[x]);
        }
    }
    inch();
    return 0;
}