Pagini recente » Cod sursa (job #2841878) | Cod sursa (job #2133931) | Cod sursa (job #1243479) | Cod sursa (job #2230174) | Cod sursa (job #2889997)
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
class EasyHash
{
private:
vector<long long> storage;
public:
EasyHash() : storage(2000000) {};
long long& operator[](const long long& nr)
{
long long index = nr % 666013;
while (storage[index] != nr && storage[index] !=0)
++index;
return storage[index];
}
};
int main()
{
ifstream in("hashuri.in");
ofstream out("hashuri.out");
EasyHash set;
int operations;
long long parameter;
short command;
in >> operations;
for(int i=0;i<operations;++i)
{
in >> command >> parameter;
switch(command)
{
case 1:
set[parameter] = parameter;
break;
case 2:
set[parameter] = 0;
break;
case 3:
out <<( (set[parameter] > 0) ? 1 : 0 )<< "\n";
}
}
in.close();
out.close();
}