Cod sursa(job #2870539)

Utilizator 100pCiornei Stefan 100p Data 12 martie 2022 13:46:32
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.93 kb
#include <bits/stdc++.h>
#define FILES freopen("hashuri.in","r",stdin);\
              freopen("hashuri.out","w",stdout);
#define fastio ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
#define MAX 100000
#define pb push_back
#define mp make_pair
#define mod 666013
using namespace std;
int n,op,x;
set<int>hs[mod+5];
int main()
{
    fastio
    FILES
    cin >> n;
    for(int i = 1;i <= n; ++i)
    {
        cin >> op >> x;
        int r = x % mod;
        if(op == 1)
        {
            auto it = hs[r].lower_bound(x);
            if(*it != x)
                hs[r].insert(x);
        }
        else if(op == 2)
        {
            auto it = hs[r].lower_bound(x);
            if(*it == x)
                hs[r].erase(it);
        }
        else
        {
            auto it = hs[r].lower_bound(x);
            if(*it == x) cout << "1\n";
            else cout << "0\n";
        }
    }
}