Cod sursa(job #2029504)

Utilizator LucaSeriSeritan Luca LucaSeri Data 30 septembrie 2017 11:11:21
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <fstream>
#include <unordered_map>
using namespace std;

const int modulo = 666013;

unordered_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;
}