Cod sursa(job #2790772)

Utilizator andu2006Alexandru Gheorghies andu2006 Data 29 octombrie 2021 15:12:18
Problema Hashuri Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.1 kb
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
FILE* fin;
char buff[1030];
int bpos=32768;
int read(){
    if(bpos==32768) bpos=0,fread(buff,1,32768,fin);
    int n=0;
    while(buff[bpos]<'0' || buff[bpos]>'9'){
        ++bpos;
        if(bpos==32768) bpos=0,fread(buff,1,32768,fin);
    }
    while(buff[bpos]>='0' && buff[bpos]<='9'){
        n=(n<<1)+(n<<3)+(buff[bpos]^48);
        ++bpos;
        if(bpos==32768) bpos=0,fread(buff,1,32768,fin);
    }
    return n;
}
unordered_set<int> s;
bool fr[30000000];
int main()
{
    fin=fopen("hashuri.in","r");
    ofstream fout("hashuri.out");
    int q=read();
    while(q--){
        int t,x;
        t=read(),x=read();
        if(x>=3e7)
        switch(t){
            case 1: s.insert(x); break;
            case 2: s.erase(x); break;
            case 3: fout<<s.count(x)<<'\n'; break;
        }
        else
        switch(t){
            case 1: fr[x]=1; break;
            case 2: fr[x]=0; break;
            case 3: fout<<fr[x]<<'\n'; break;
        }
    }
    return 0;
}