Cod sursa(job #348364)

Utilizator serbanlupulupulescu serban serbanlupu Data 15 septembrie 2009 16:41:53
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.94 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

#define PRIM 666203

vector<int > H[PRIM];

int check(int temp)
{
	vector<int >::iterator it;

	for (it=H[temp%PRIM].begin(); it<H[temp%PRIM].end(); it++)
		if (*it == temp)
			return 1;
	return 0;
}

void del(int temp)
{
	int i;
	for (i=0; i<=H[temp%PRIM].size()-1; ++i)
		if (H[temp%PRIM][i] == temp)
			return;
	swap (H[temp%PRIM][i], H[temp%PRIM][H[temp%PRIM].size()-1]);
	H[temp%PRIM].pop_back();
}

void solve()
{
	fstream f("hashuri.in", ios::in);
	fstream g("hashuri.out", ios::out);

	int n, aux, temp;
	f>>n;

	for (int i=1; i<=n; ++i)
	{
		f>>aux;
		if (aux == 1)
		{
			f>>temp;
			if (check(temp) == 0)
				H[temp%PRIM].push_back(temp);
		}
		if (aux == 2)
		{
			f>>temp;
			del(temp);
		}
		if (aux == 3)
		{
			f>>temp;
			g<<check(temp)<<"\n";
		}
	}
	f.close();
	g.close();
}

int main()
{
	return 0;
}