Cod sursa(job #2850423)

Utilizator betybety bety bety Data 16 februarie 2022 19:14:41
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
typedef long long ll;
struct custom_hash
{
    static ll splitmix64(ll x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(ll x) const
    {
        static const ll FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_set<ll,custom_hash> s;
ll q,t,x;
int main()
{
    in>>q;
    while(q--)
    {
        in>>t>>x;
        if(t==1) s.insert(x);
        else if(t==2)
        {
            if(s.count(x))
                s.erase(s.find(x));
        }
        else
        {
            if(s.count(x))
                out<<1<<'\n';
            else out<<0<<'\n';
        }
    }
    return 0;
}