Pagini recente » Cod sursa (job #421303) | Cod sursa (job #1220308) | Cod sursa (job #975610) | Cod sursa (job #1143873) | Cod sursa (job #222403)
Cod sursa(job #222403)
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MAXN 3510
using namespace std;
struct cutie {
int x, y, z;
};
int n, t, i, j, rez, x[MAXN];
cutie v[MAXN];
bool cmp(cutie a, cutie b) {
if ((a.z < b.z) || ((a.z == b.z) && (a.x < b.x)) || ((a.z == b.z) && (a.x == b.x) && (a.y < b.y)))
return true;
else
return false;
}
bool cmp2(cutie a, cutie b) {
if (a.x < b.x && a.y < b.y && a.z < b.z)
return true;
else
return false;
}
void read() {
int i;
memset(v, 0, sizeof(v));
memset(x, 0, sizeof(x));
rez = 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);
}
void solve() {
int i, j;
rez = 0;
x[1] = 1;
for (i = 2; i <= n; i++) {
x[i] = 1;
for (j = 1; j < i; j++)
if (cmp2(v[j], v[i]) && (x[j] + 1 > x[i]))
x[i] = x[j] + 1;
}
for (i = 1; i <= n; i++)
if (x[i] > rez)
rez = x[i];
}
int main() {
freopen("cutii.in", "r", stdin);
freopen("cutii.out", "w", stdout);
scanf("%d%d", &n, &t);
for (i = 1; i <= t; i++) {
read();
solve();
printf("%d\n", rez);
}
return 0;
}