Cod sursa(job #2889997)

Utilizator widzAndrei-Daniel Tava widz Data 14 aprilie 2022 08:26:16
Problema Hashuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.83 kb
#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();

	
}