Pagini recente » Cod sursa (job #2461427) | Cod sursa (job #160807) | Cod sursa (job #2486312) | Cod sursa (job #1249285) | Cod sursa (job #354939)
Cod sursa(job #354939)
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct Cutie
{
int x, y, z;
bool operator < (const Cutie &cutie) const
{
if (x < cutie.x)
return true;
if (x > cutie.x)
return false;
if (y < cutie.y)
return true;
if (y > cutie.y)
return false;
if (z < cutie.z)
return true;
return false;
}
};
bool intra(const Cutie &c1, const Cutie &c2)
{
if (c1.x < c2.x && c1.y < c2.y && c1.z < c2.z)
return true;
return false;
}
Cutie cutie[3];
int best[3];
int main()
{
freopen("cutii.in", "rt", stdin);
freopen("cutii.out", "wt", stdout);
int n, t;
scanf("%d%d", &n, &t);
for (int i = 0; i < t; i++)
{
memset(best, 0, n * sizeof(int));
for (int j = 0; j < n; j++)
{
scanf("%d%d%d", &cutie[j].x, &cutie[j].y, &cutie[j].z);
}
sort(cutie, cutie + n);
for (int j = 1; j < n; j++)
{
for (int k = 0; k < j; k++)
{
if (intra(cutie[k], cutie[j]) && best[k] >= best[j])
{
best[j] = best[k + 1] + 1;
}
}
}
int sol = 0;
for (int j = 0; j < n; j++)
if (sol < best[j])
sol = best[j];
printf("%d\n", sol + 1);
}
return 0;
}