Cod sursa(job #2419158)

Utilizator AlexBolfaAlex Bolfa AlexBolfa Data 7 mai 2019 18:35:58
Problema Hashuri Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <bits/stdc++.h>
#define MAX 100000
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

set<int> A[MAX+5];
set<int>::iterator it;
int n,a,b,x,h;
int main(){
    fin>>n;
    while(n--){
        fin>>a>>b;
        h=b%MAX;
        x=b;
        while(x){
            h+=x%10;
            x/=10;
        }
        if(a==1){
            A[h].insert(b);
        }else if(a==2){
            A[h].erase(b);
        }else{
            it=A[h].find(b);
            if(it!=A[h].end())fout<<"1\n";
            else fout<<"0\n";
        }
    }
    return 0;
}