Cod sursa(job #3130417)
Utilizator | Data | 17 mai 2023 19:04:58 | |
---|---|---|---|
Problema | Hashuri | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.65 kb |
#include<iostream>
#include<fstream>
#include<unordered_map>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int main() {
int n,i,op,nr;
unordered_map<int, int> hash;
fin>>n;
for (i=0; i<n; i++){
fin>>op>>nr;
if (op == 1)
{if (hash.count(nr) == 0)
{hash[nr] = 1;}}
else if (op == 2) {
if (hash.count(nr) == 1)
{hash.erase(nr);}}
else if (op == 3)
{if (hash.count(nr) !=0)
{fout << "1" << endl;}
else
{fout << "0" << endl;}
}
}
fin.close();
fout.close();
}