Cod sursa(job #2764645)

Utilizator Tudor_StefanaStefana Tudor Tudor_Stefana Data 21 iulie 2021 22:02:15
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.64 kb
#include <fstream>
#include <map>
using namespace std;

const int modulo = 666013;

map<int, int> cnt[modulo+10];
ifstream f("hashuri.in");
ofstream g("hashuri.out");

int main(){
    int n;
    f >> n;
    for(int i = 0 ; i< n; ++ i){
        int cd, x;
        f >> cd >> x;
        int y = x % modulo;
        if(cd == 1){
            cnt[y][x]++;
        }
        if(cd == 2){
            if(cnt[y].count(x) == 0) continue;
            else cnt[y].erase(x);
        }
        if(cd == 3){
            if(cnt[y].count(x) == 0) g << 0;
            else g << 1;
            g << '\n';
        }
    }
    return 0;
}