Cod sursa(job #3315293)

Utilizator batasAndrei Batis batas Data 13 octombrie 2025 17:44:01
Problema Cutii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream fin("cutii.in");
ofstream fout("cutii.out");

struct Cutie {
    int x, y, z;
};

const int DIM = 3505;
int n, t;
int lmax;
Cutie a[DIM];
int L[DIM];

void CMLSC();

int main()
{
    fin >> n >> t;

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

        CMLSC();

        fout << lmax << '\n';
    }

    return 0;
}

void CMLSC()
{
    lmax = -1;

    for (int i = 1; i <= n; ++i)
        L[i] = 0;

    for (int i = 1; i <= n; ++i)
    {
        L[i] = 1;
        for (int j = 1; j < i; ++j)
            if (L[j] + 1 > L[i] && a[i].x > a[j].x && a[i].y > a[j].y && a[i].z > a[j].z)
                L[i] = L[j] + 1;
        lmax = max(lmax, L[i]);
    }
}