Cod sursa(job #221209)

Utilizator Mishu91Andrei Misarca Mishu91 Data 14 noiembrie 2008 22:21:27
Problema Cutii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.92 kb
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define MAX_N 3505

struct lx{int x, y, z;} A[MAX_N];
int Deg[MAX_N], Sol;
int N, T;

struct cmp
{
    bool operator ()(const lx a, const lx b) const
    {
        return ((a.x < b.x) && (a.y < b.y) && (a.z < b.z));
    }
};

void solve()
{
    for(int i = 0; i < N; ++i)
        scanf("%d %d %d",&A[i].x, &A[i].y, &A[i].z);

    sort(A, A+N, cmp());

    Sol = 0;
    memset(Deg, 0, sizeof Deg);
    for(int i = 0; i+1 < N; ++i)
        for(int j = i+1; j < N; ++j)
            if(A[i].x < A[j].x && A[i].y < A[j].y && A[i].z < A[j].z)
            {
                Deg[j] = max(Deg[j], (Deg[i] + 1));
                if(Deg[j] > Sol)
                    Sol = Deg[j];
            }

    printf("%d\n", Sol + 1);
}

int main()
{
    freopen("cutii.in","rt",stdin);
    freopen("cutii.out","wt",stdout);

    scanf("%d %d",&N, &T);

    while(T--)
        solve();
}