Cod sursa(job #2450953)

Utilizator r00t_Roman Remus r00t_ Data 25 august 2019 10:49:52
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.07 kb
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <math.h>
#include <queue>
#include <string>
#include <map>

using namespace std;

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

#define MOD 666013
vector<int>vp[666013];

namespace hashing
{
	void insert_value(int x)
	{
		int index = x % MOD;
		if (find(vp[index].begin(), vp[index].end(), x) == vp[index].end())
			vp[index].push_back(x);
	}

	void erase_value(int x)
	{
		int index = x % MOD;
		vector<int>::iterator it = find(vp[index].begin(), vp[index].end(), x);
		if (it != vp[index].end())
			vp[index].erase(it);
	}




}

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	fin >> n;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		fin >> a >> b;
		if (a == 1)
			hashing::insert_value(b);
		if (a == 2)
			hashing::erase_value(b);
		if (a == 3)
		{
			int index = b % MOD;
			if (find(vp[index].begin(), vp[index].end(), b) != vp[index].end())
				fout << "1\n";
			else
				fout << "0\n";
		}
	}

	
}