Pagini recente » Cod sursa (job #2986270) | Cod sursa (job #2211786) | Cod sursa (job #3205973) | Cod sursa (job #2304105) | Cod sursa (job #998478)
Cod sursa(job #998478)
#include <fstream>
#include <algorithm>
using namespace std;
const int MAX_N = 3502;
struct box {
int x, y, z;
};
int N, T;
int dp[MAX_N];
box v[MAX_N];
inline bool box_cmp(box a, box b) {
return (a.x < b.x && a.y < b.y && a.z < b.z);
}
int main() {
ifstream f("cutii.in");
ofstream g("cutii.out");
f >> N >> T;
while(T--) {
for(int i = 1; i <= N; ++i)
f >> v[i].x >> v[i].y >> v[i].z;
sort(v+1, v+N+1, box_cmp);
int sol = 0;
for(int i = 1; i <= N; ++i) {
dp[i] = 0;
for(int j = 1; j < i; ++j)
if(box_cmp(v[j], v[i]) && dp[j] > dp[i])
dp[i] = dp[j];
++dp[i];
sol = max(sol, dp[i]);
}
g << sol << "\n";
}
f.close();
g.close();
return 0;
}