Pagini recente » Cod sursa (job #2556855) | Cod sursa (job #1643205) | Cod sursa (job #1495862) | Cod sursa (job #349167) | Cod sursa (job #368773)
Cod sursa(job #368773)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
struct Puncte {
int x;
int y;
int z;
} p[3501];
int cmp(Puncte a, Puncte b) {
if(a.z!=b.z) {
return a.z>b.z;
}
}
int main() {
fstream f1, f2;
int n, t, i, j, k, x, y, z, maxi, dan;
int l[3501];
f1.open("cutii.in", ios::in);
f2.open("cutii.out", ios::out);
f1>>n>>t;
for(i=1; i<=t; i++) {
for(j=0; j<n; j++) {
f1>>p[j].x>>p[j].y>>p[j].z;
}
sort(p, p+n, cmp);
l[0]=1; dan=-1000;
for(j=1; j<n; j++) {
maxi=1;
for(k=0; k<j; k++) {
if(p[k].x>p[j].x && p[k].y>p[j].y && p[k].z>p[j].z) {
if(maxi<l[k]+1) {
maxi=l[k]+1;
}
}
}
l[j]=maxi;
if(l[j]>dan) {
dan=l[j];
}
}
f2<<dan<<endl;
}
f1.close(); f2.close();
return 0;
}