Cod sursa(job #2850430)

Utilizator betybety bety bety Data 16 februarie 2022 19:18:36
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.06 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
typedef long long ll;
using tip=int;
struct custom_hash
{
    static tip splitmix64(tip 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()(tip x) const
    {
        static const tip FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_set<tip,custom_hash> s;
//unordered_set<tip> s;
tip q,t,x;
int main()
{
    in>>q;
    while(q--)
    {
        in>>t>>x;
        if(t==1) s.insert(x);
        else if(t==2)
        {
            if(s.find(x)!=s.end())
                s.erase(s.find(x));
        }
        else
        {
            if(s.find(x)!=s.end())
                out<<'1'<<'\n';
            else out<<'0'<<'\n';
        }
    }
    return 0;
}