Cod sursa(job #3198917)

Utilizator gabiccGabriel Cocan gabicc Data 31 ianuarie 2024 00:12:42
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.99 kb
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <set>

using namespace std;

#define NR 100003

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

vector<set<int>> multime;

int main()
{
    int n, instr, val;
    fin >> n;
    multime.resize(NR);
    for(int i = 1; i <= n; ++i){
        fin >> instr >> val;
        switch(instr){
            case 1:{
                int hashh = val % NR;
                multime[hashh].insert(val);
                break;
            }

            case 2:{
                int hashh = val % NR;
                multime[hashh].erase(val);
                break;
            }

            case 3:{
                int hashh = val % NR;
                auto it = multime[hashh].find(val);
                if(it == multime[hashh].end())
                    fout << 0 << '\n';
                else fout << 1 << '\n';
                break;
            }
        }
    }
    return 0;
}