Cod sursa(job #655819)

Utilizator vendettaSalajan Razvan vendetta Data 3 ianuarie 2012 15:07:19
Problema Cutii Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 1 kb
#include <fstream>
#include <algorithm>
#define nmax 3501
#define x first
#define y second
using namespace std;

int l[nmax];
int n, t;
pair<int, pair<int,int> > v[nmax];

ifstream f("cutii.in");
ofstream g("cutii.out");

void citeste(){

   f>>n>>t;

}

void cit(){

   for(int i=1; i<=n; ++i){
      int x,y,z;
      f>>x>>y>>z;
      v[i] = make_pair(x,make_pair(y,z));
   }

   sort(v+1,v+n+1);

}

void rezolva(){

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

   for(int i=n-1; i>=1; i--){
      mx = 0;
      for(int j=i+1; j<=n; ++j)
         if (v[j].x > v[i].x && v[j].y.x > v[i].y.x && v[j].y.y > v[i].y.y && mx < l[j] ) mx = l[j];
      l[i] = mx + 1;
   }


   mx = 0;
   for(int i=1; i<=n; ++i){
      if (mx < l[i]) mx = l[i];
   }

   g<<mx<<"\n";

}

void rez(){

   for(int i=1; i<=t; ++i){
      cit();
      rezolva();
   }

}
int main(){


   citeste();
   rez();

   f.close();
   g.close();
   return 0;

}