Pagini recente » Cod sursa (job #1037811) | Cod sursa (job #2607200) | Cod sursa (job #1499349) | Cod sursa (job #2909359) | Cod sursa (job #2803942)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("cutii.in");
ofstream fout("cutii.out");
#define DIM 3500
int n, t, L[DIM + 1];
pair<int, pair<int, int>> v[DIM + 1];
static inline bool Inside_box(pair<int, pair<int, int>> x, pair<int, pair<int, int>> y) { //verific daca cutia y incape in x;
return(y.first < x.first && y.second.first < x.second.first && y.second.second < x.second.second);
}
int main() {
fin.tie(0);
fout.tie(0);
fin >> n >> t;
while(t--) {
for(int i = 1; i <= n; i++)
fin >> v[i].first >> v[i].second.first >> v[i].second.second;
sort(v + 1, v + n + 1);
for(int i = 1; i <= n; i++)
L[i] = 0;
L[1] = 1;
int lgmax = 0;
for(int i = 2; i <= n; i++) {
int maxim = 0;
for(int j = 1; j < i; j++)
if(Inside_box(v[i], v[j]) && maxim < L[j])
maxim = L[j];
L[i] = maxim + 1;
lgmax = max(lgmax, L[i]);
}
fout << lgmax << '\n';
}
return 0;
}