Cod sursa(job #2661699)

Utilizator proflaurianPanaete Adrian proflaurian Data 22 octombrie 2020 15:52:59
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.81 kb
#include <bits/stdc++.h>

using namespace std;
char buff[32000];
int p;
void inc()
{
    p++;
    if(p==32000)
    {
        p=0;
        fread(buff,32000,1,stdin);
    }
}
void read(int &x)
{
    while(buff[p]<'0'||buff[p]>'9')
        inc();
    x=0;
    while(buff[p]>='0'&&buff[p]<='9')
    {
        x=10*x+buff[p]-'0';
        inc();
    }
}
int n,t,x;
unordered_set<int> s;
int main()
{
    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);
    read(n);///f>>n;
    for(; n; n--)
    {
        read(t);read(x);///f>>t>>x;
        if(t==1)
            s.insert(x);
        else if(t==2)
            s.erase(x);
        else if(s.find(x)==s.end())
            printf("0\n");///g<<"0\n";
        else
            printf("1\n");///g<<"1\n";
    }
    return 0;
}