Pagini recente » Cod sursa (job #1091237) | Cod sursa (job #2700804) | Cod sursa (job #1329205) | Cod sursa (job #2766136) | Cod sursa (job #7593)
Cod sursa(job #7593)
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
struct cutie
{
int x, y, z;
};
bool cmp(cutie a, cutie b)
{
return a.x < b.x;
}
int n, t, len[3501], sol;
cutie v[3501];
int main()
{
freopen("cutii.in","r",stdin);
freopen("cutii.out","w",stdout);
int test, i, j;
scanf("%d%d", &n, &t);
for(test = 1; test <= t; ++test)
{
sol = 0;
for(i = 1; i <= n; ++i)
{
scanf("%d%d%d", &v[i].x, &v[i].y, &v[i].z);
}
sort(v + 1, v + n + 1, cmp);
memset(len, 0, sizeof(len));
for(i = n; i >= 1; --i)
{
for(j = i + 1; j <= n; ++j)
{
if(v[i].y < v[j].y && v[i].z < v[j].z && len[i] < len[j] + 1)
{
len[i] = len[j] + 1;
}
}
if(len[i] == 0)
{
len[i] = 1;
}
}
for(i = 1; i <= n; ++i)
{
if(sol < len[i])
{
sol = len[i];
}
}
printf("%d\n",sol);
}
return 0;
}