Cod sursa(job #595253)

Utilizator veleanduAlex Velea veleandu Data 11 iunie 2011 18:33:29
Problema Cutii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include<fstream>
using namespace std;
typedef struct { long x,y,z; } punct;
long i,j,n,t,l,maxim;
long REZ[3505];
punct T[3505];
bool myfct ( punct a, punct b)
{
	if ( a.x < b.x )
		return 1;
	return 0;
}
int main()
{
	ifstream in("cutii.in");
	ofstream out("cutii.out");
	in>>n>>t;
	for ( i=1; i<=t; i++ )
	{
		for ( j=1; j<=n; j++ )
			in>>T[j].x>>T[j].y>>T[j].z;
		sort(T+1,T+n+1,myfct);
		for ( j=1; j<=n; j++ )
			REZ[j]=1;
		for ( j=1; j<=n;j++)
			for ( l=j+1; l<=n; l++ )
				if ( T[j].y<T[l].y && T[j].z<T[l].z && REZ[j]+1>REZ[l] )
					REZ[l]=REZ[j]+1;
		maxim=0;
		for ( j=1; j<=n; j++ )
			if (REZ[j]>maxim)
				maxim=REZ[j];
		out<<maxim<<"\n";
	}
	
	return 0;
}