Cod sursa(job #3268895)

Utilizator Radu_BicliBiclineru Radu Radu_Bicli Data 17 ianuarie 2025 22:01:55
Problema Cutii Scor 0
Compilator cpp-64 Status done
Runda cex_7 Marime 0.81 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("cutii.in");
ofstream fout("cutii.out");
struct Cutie {
    int x, y, z;

    bool operator<(Cutie c) const {
        return x < c.x;
    }
} c[3502];
int n, t, i, j, lg[3502], rasp;

static inline bool Incape(Cutie a, Cutie b) {
    return (a.x > b.x && a.y > b.y && a.z > b.z);
}

int main() {
    fin >> n >> t;
    while(t--) {
        for(i = 1; i <= n; i++) fin >> c[i].x >> c[i].y >> c[i].z;
        sort(c + 1, c + n + 1);

        rasp = 0;
        for(i = 1; i <= n; i++) {
            lg[i] = 1;
            for(j = 1; j < i && Incape(c[i], c[j]); j++) {
                lg[i] = max(lg[i], lg[j] + 1);
            }
            rasp = max(rasp, lg[i]);
        }
        fout << rasp << "\n";
    }

    return 0;
}