Cod sursa(job #40893)

Utilizator crawlerPuni Andrei Paul crawler Data 27 martie 2007 20:25:21
Problema Cutii Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.1 kb
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

#define Nmax 3501
#define fin "cutii.in"
#define fout "cutii.out"
#define x first
#define y second.first
#define z second.second
#define all(x) x.begin(),x.end()
#define mk make_pair
#define pb push_back
#define FOR(i,a,b) for(i=(a);i<(b);++i)
#define cmp(i,j) ((c[i].x > c[j].x) && (c[i].y > c[j].y) && (c[i].z > c[j].z))

vector<pair< int , pair<int,int> > > c;

int x[Nmax];

int main()
 {
   freopen(fin,"r",stdin);
   freopen(fout,"w",stdout);

   register int n,t,i,j, q,e,w, tmp, Max,sol;

   scanf("%d%d", &n, &t);

   do
    {
     --t;
     
     c.clear();
     
     FOR(i,0,n)
      {
       scanf("%d%d%d", &q, &w, &e);
       c.pb(mk(q,mk(w,e)));
      }

     sort(all(c));

     tmp = c.size();
     sol = 0;

     FOR(i,0,tmp)
      {
       Max = 0;
       FOR(j,0,i)
        if(cmp(i,j) && (x[j]>Max))
         Max = x[j];
       x[i] = ++Max;
       sol = max(sol,Max);
      }
     
     printf("%d\n", sol);

    }while(t);

   return 0;
 }