Cod sursa(job #580117)

Utilizator tinkyAndrei Ilisei tinky Data 12 aprilie 2011 19:24:25
Problema Cutii Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.85 kb
#include<fstream>
#define nmax 3510
using namespace std;
struct asd{int x,y,z;};
asd v[nmax];
int sol[nmax];
bool cmp(asd a,asd b)
{
	if (a.x!=b.x)
		if (a.x<b.x)
			return true;
		else
			return false;
	if (a.y!=b.y)
		if (a.y<b.y)
			return true;
		else
			return false;
	if (a.z<b.z)
		return true;
	return false;
}
int incape (asd a,asd b)
{
	if (a.y<b.y&&a.z<b.z)
		return 1;
	return 0;
}
int main()
{
	int i,j,n,t,mx;
	ifstream in("cutii.in");
	ofstream out("cutii.out");
	in>>n>>t;
	while (t)
	{
		for (i=1;i<=n;i++)
			in>>v[i].x>>v[i].y>>v[i].z;
		sort (v+1,v+n+1,cmp);
		memset(sol,0,sizeof(sol));
		for (i=n-1;i>0;i--)
			for (j=i+1;j<=n;j++)
			{
				if (incape (v[i],v[j])&&sol[i]<sol[j]+1)
					sol[i]=sol[j]+1;
			}
		mx=0;
		for (i=1;i<n;i++)
			mx=max(mx,sol[i]);
		out<<mx+1<<'\n';
		t--;
	}
}