Cod sursa(job #2601843)

Utilizator 1chiriacOctavian Neculau 1chiriac Data 15 aprilie 2020 12:17:28
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.81 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
vector <int> hashuri[666668];
const int a=666667;
int main ()
{
	bool ok;int n,x,operatie;
	fin>>n;
	for(int i=0;i<n;i++)
	{
		fin>>operatie>>x;
		if(operatie==1)
		{
			ok=true;
			for(int ii=0;ii<hashuri[x%a].size();++ii)
				if(hashuri[x%a][ii]==x)
				{
					ok=false;
					break;
				}
			if(ok==true)
				hashuri[x%a].push_back(x);
		}
		else if(operatie==2)
		{
			//ok=true;
			for(int ii=0;ii<hashuri[x%a].size();++ii)
				if(hashuri[x%a][ii]==x)
				{
					hashuri[x%a].erase(hashuri[x%a].begin()+ii);
					break;
				}
		}
		else
		{
			ok=true;
			for(int ii=0;ii<hashuri[x%a].size();++ii)
				if(hashuri[x%a][ii]==x)
				{
					fout<<"1\n";
					ok=false;break;
				}
			if(ok==true)
				fout<<"0\n";
		}
	}
}