Cod sursa(job #947571)

Utilizator tibi9876Marin Tiberiu tibi9876 Data 7 mai 2013 20:07:10
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.77 kb
#include<fstream>
#include<vector>
using namespace std;

vector <int> a[1000000];
int v,x,i,n,m,j,y;
bool ok;

int main()
{
	ifstream f("hashuri.in");
	ofstream g("hashuri.out");
	f >> n;
	for (i=1;i<=n;i++)
	{
		f >> v >> x;
		y=x*50%n;
		if (v==1)
		{
			ok=false;
			for (j=0;j<a[y].size();j++)
				if (x==a[y][j])
				{
					ok=true;
					break;
				}
			if (!ok)
				a[y].push_back(x);
		}
		else if (v==2)
		{
			m=a[y].size();
			for (j=0;j<m;j++)
				if (x==a[y][j])
				{
					swap(a[y][j],a[y][m-1]);
					a[y].pop_back();
				}
		}
		else 
		{
			ok=false;
			for (j=0;j<a[y].size();j++)
				if (x==a[y][j])
				{
					g << 1 << "\n";
					ok=true;
					break;
				}
			if (!ok)
				g << 0 << "\n";
		}
	}
	return 0;
}