Cod sursa(job #91452)
#include<stdio.h>
#include<stdlib.h>
int n, t, max, best[3600];
typedef struct
{
int a, b, c;
} cutie;
cutie v[3600], a[3600];
void calcul()
{
freopen("cutii.in","r",stdin);
freopen("cutii.out","w",stdout);
scanf ("%d %d", &n, &t);
int i, k, j, ord[3600];
for (k=1; k<=t; k++)
{
max=0;
for (i=1; i<=n; i++)
{ scanf("%d %d %d", &v[i].a, &v[i].b,&v[i].c); ord[i]=i;}
for (i=1; i<=n; i++) a[i]=v[i], best[i]=0;
best[n]=1;
for (i=n-1; i>=1; i--)
for (j=i+1; j<=n; j++)
{
if (a[j].b>a[i].b && a[j].a>a[i].a && a[j].c>a[i].c)
if (best[i]<=best[j]) best[i]=best[j]+1;
if(best[i]==0) best[i]=1;
}
max=best[1];
for (i=2; i<=n;i++) if (best[i]>max) max=best[i];
printf("%d\n",max);
}
}
int main()
{
calcul();
return 0;
}