Cod sursa(job #2037593)

Utilizator adi1607Ciurea Adi adi1607 Data 12 octombrie 2017 16:07:15
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int M=666013;
vector<int>H[M+5];
vector<int>:: iterator it;
int hash(int k)
{
	return k%M;
}
int main()
{
	int n,o,a,i,x;
	in>>n;
	for(i=0;i<n;i++)
	{
		in>>o;
		in>>a;
		x=hash(a);
		it=find(H[x].begin(),H[x].end(),a);
		if(o==1)
		{
			if(it==H[x].end())
				H[x].push_back(a);
		}
		if(o==2)
		{
			if(it!=H[x].end())
				H[x].erase(it);
		}
		if(o==3)
		{
			if(it!=H[x].end())
				out<<1<<'\n';
			else
				out<<0<<'\n';
		}
	}
    return 0;
}