Cod sursa(job #2802614)

Utilizator Andrei012Trache Andrei Andrei012 Data 18 noiembrie 2021 15:30:53
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.73 kb
#include <bits/stdc++.h>
#define mod 999983;
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
set<int> rest[999984];
int main(){
    int n,m,c,x,r,i;
    in>>n;
    for(i=1;i<=n;++i){
        in>>c>>x;
        r=x%mod;
        if(c==1)
        {
            if(rest[r].find(x) == rest[r].end())
                rest[r].insert(x);
        }
        else
            if(c==2)
            {
                if(rest[r].find(x) != rest[r].end())
                    rest[r].erase(x);
            }
            else
            {
                if(rest[r].find(x) == rest[r].end())
                    out<<0<<'\n';
                else
                    out<<1<<'\n';
            }
    }
}