Cod sursa(job #1409537)
Utilizator | Tudor Coman tudorcoman | Data | 30 martie 2015 16:17:44 |
---|---|---|---|
Problema | Hashuri | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.91 kb |
#include <fstream>
#include <unordered_set>
using namespace std;
typedef unordered_set<int> hashy;
hashy V;
int main(int argc, const char * argv[]) {
ifstream fi ("hashuri.in");
ofstream fo ("hashuri.out");
int P,op,n;
for (fi >> P; P ; -- P)
{
fi >> op >> n;
switch (op)
{
case 1: V.insert(n); break;
default:
{
hashy::const_iterator pointer = V.find(n);
if (pointer == V.end())
{
if (op == 3)
fo << 0 << '\n';
}
else
{
if (op == 2)
V.erase(n);
else fo << 1 << '\n';
}
break;
}
}
}
return 0;
}