Pagini recente » Cod sursa (job #2983855) | Cod sursa (job #1504899) | Cod sursa (job #2375047) | Cod sursa (job #2951945) | Cod sursa (job #149582)
Cod sursa(job #149582)
#include<stdio.h>
#include<algorithm>
#define NMAX 4000
using namespace std;
struct kkt
{
long X,Y,Z;
};
kkt x[NMAX];
long z[NMAX],i,j,n,m,k,l,t,tt,rez,s;
int cmpf(const kkt a,const kkt b)
{
return ((a.X>b.X)||(a.X==b.X&&a.Y>b.Y)||(a.X==b.X&&a.Y==b.Y&&a.Z>=b.Z));
}
int main()
{
freopen("cutii.in","r",stdin);
freopen("cutii.out","w",stdout);
scanf("%ld%ld",&n,&t);
for (tt=1;tt<=t;tt++)
{
for (i=1;i<=n;i++)
scanf("%ld%ld%ld",&x[i].X,&x[i].Y,&x[i].Z);
sort(x+1,x+n+1,cmpf);
z[1]=1;
rez=1;
for (i=2;i<=n;i++)
{
s=-1;
for (j=1;j<i;j++)
if (s<z[j]&&x[i].X<x[j].X&&x[i].Y<x[j].Y&&x[i].Z<x[j].Z)
s=z[j];
z[i]=s+1;
if (z[i]>rez)
rez=z[i];
}
printf("%ld\n",rez);
}
return 0;
}