Cod sursa(job #719027)

Utilizator avram_florinavram florin constantin avram_florin Data 21 martie 2012 12:35:14
Problema Cutii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#include<fstream>
#include<cstdio>
#include<cstring>

using namespace std;

const int MaxN = 3501;

const char InFile[] = "cutii.in";
const char OutFile[] = "cutii.out";

int N,T,Best,bst[MaxN];
struct box
{
	int x,y,z;
}Box[MaxN];

ifstream fin( InFile );
ofstream fout( OutFile );

void read()
{
	for( int i = 1 ; i <= N ; ++i )
		fin >> Box[i].x >> Box[i].y >> Box[i].z;
}

void solve()
{
	Best = 0;
	memset(bst,0,sizeof(bst));
	int i,j;
	bst[N] = 1;
	for( i = N-1 ; i ; --i )
		{
			bst[i] = 1;
			for( j = i+1 ; j <= N ; ++j )
				if( Box[i].x < Box[j].x && Box[i].y < Box[j].y && Box[i].z < Box[j].z && bst[i] < bst[j] + 1 )
					{
						bst[i] = bst[j] + 1;
						if( bst[i] > Best )
							Best = bst[i];
					}
		}
}

int main()
{
	fin >> N >> T;
	for( ; T ; --T )
		{
			read();
			solve();
			fout << Best << '\n';
		}
	fin.close();fout.close();
	return 0;
}