Pagini recente » Cod sursa (job #1899013) | Monitorul de evaluare | Cod sursa (job #521812) | Cod sursa (job #83127) | Cod sursa (job #3338418)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream fin("cutii.in");
ofstream fout("cutii.out");
const int MAXN = 3502;
struct elem {
int x, y, z;
bool operator<(const elem& other) const {
return x < other.x || (x == other.x && y < other.y) || (x == other.x && y == other.y && z < other.z);
}
bool fits(const elem& other) const {
return x < other.x && y < other.y && z < other.z;
}
};
int N, T;
elem v[MAXN];
int d[MAXN];
int main()
{
fin >> N >> T;
for (int t = 0; t < T; ++t) {
for (int i = 0; i < N; ++i) {
fin >> v[i].x >> v[i].y >> v[i].z;
}
sort(v, v + N);
int ans = 0;
for (int i = 0; i < N; ++i) {
d[i] = 1;
for (int j = 0; j < i; ++j) {
if (v[j].fits(v[i])) {
d[i] = max(d[i], d[j] + 1);
}
}
ans = max(ans, d[i]);
}
fout << ans << '\n';
}
return 0;
}