Cod sursa(job #365307)

Utilizator AndreiDDiaconeasa Andrei AndreiD Data 18 noiembrie 2009 13:29:28
Problema Cutii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <cstdio>
#include <cstring>

#define file_in "cutii.in"
#define file_out "cutii.out"

int N,T,i,j,best[10000],x[3501],y[3501],z[3501],v[10100],cmax;

int main()
{
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);
	
	scanf("%d %d", &N, &T);
	
	while(T--)
	{
		for (i=1;i<=N;++i)
		{
			scanf("%d %d %d", &x[i], &y[i], &z[i]);
		}
		
		cmax=0;
		
		memset(best,0,sizeof(best));
		
		best[N]=1;
		
		for (i=N-1;i>=1;--i)
		{
			best[i]=1;
			
			for (j=i+1;j<=N;++j)
				if (x[i]<x[j] && y[i]<y[j] && z[i]<z[j] && best[i]<best[j]+1)
					best[i]=best[j]+1;
			if (best[i]>cmax)
                cmax=best[i];
        }
		
		printf("%d\n", cmax);
	}
	
	fclose(stdin);
	fclose(stdout);
	
	return 0;
	
}