Pagini recente » Cod sursa (job #2492012) | Cod sursa (job #108648) | Cod sursa (job #1897530) | Cod sursa (job #2581524) | Cod sursa (job #3149127)
#include <stdio.h>
#include<algorithm>
#define dim 3505
using namespace std;
struct box
{
int x, y, z;
} v[dim];
int test_cases, n, maxi;
int best[dim];
inline bool compare(box a, box b)
{
if(a.x == b.x)
{
if(a.y == b.y)
{
if(a.z > b.z)
{
return 0;
}
else
{
return 1;
}
}
else
{
if(a.y < b.y)
{
return a.y < b.y;
}
else
{
return 0;
}
}
}
else
{
if(a.x < b.x)
{
return a.x < b.x;
}
else
{
return 0;
}
}
}
inline bool verif(box a, box b)
{
return (a.x < b.x && a.y < b.y && a.z < b.z);
}
int main(int argc, char * argv[])
{
freopen("cutii.in","r",stdin);
freopen("cutii.out","w",stdout);
scanf("%d %d\n",&n,&test_cases);
while(test_cases--)
{
maxi = 0;
for(int i = 1; i <= n; ++i)
{
scanf("%d %d %d\n",&v[i].x,&v[i].y,&v[i].z);
}
sort(v + 1, v + n + 1, compare);
maxi = 0;
for(int i = 1; i <= n; ++i)
{
best[i] = 1;
for(int j = i - 1; j >= 1; --j)
{
if(best[j] + 1 > best[i] && verif(v[j], v[i]))
{
best[i] = best[j] + 1;
maxi = max(best[i], maxi);
}
}
}
printf("%d\n",maxi);
}
return 0;
}