Cod sursa(job #2790769)

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

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