Pagini recente » Cod sursa (job #372917) | Cod sursa (job #643157)
Cod sursa(job #643157)
#include <cstdio>
#define file_in "cutii.in"
#define file_out "cutii.out"
#define nmax 5010
int N,T;
int i,max,j;
int x[nmax];
int y[nmax];
int z[nmax];
int best[nmax];
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]);
max=0;
best[N]=1;
for (i=N-1;i>=1;--i){
best[i]=1;
for (j=i+1;j<=N;++j)
if (best[i]<best[j]+1 && x[i]<=x[j] && y[i]<=y[j] && z[i]<=z[j])
best[i]=best[j]+1;
if (best[i]>max) max=best[i];
}
printf("%d\n", max);
}
return 0;
}