Cod sursa(job #2650293)

Utilizator Florinos123Gaina Florin Florinos123 Data 18 septembrie 2020 09:45:00
Problema Cutii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <fstream>

using namespace std;

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

struct cutie {
 int x, y, z;
}v[3505];

int n, t, rez;
int sol[3505];

bool Check (int i, int j)
{
    if (v[i].x < v[j].x)
     if (v[i].y < v[j].y)
      if (v[i].z < v[j].z)
        return true;
      return false;
}

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

   while (t --)
   {
       for (int i=1; i<=n; i++)
       {
           f >> v[i].x;
           f >> v[i].y;
           f >> v[i].z;
           sol[i] = 1;
       }

       for (int i=1; i<=n; i++)
       {
           for (int j=1; j<i; j++)
           {
               if (Check(j, i))
               {
                   int aux = sol[j] + 1;
                   if (aux > sol[i])
                      sol[i] = aux;
               }
           }
       }

       rez = 0;
       for (int i=1; i<=n; i++)
         rez = max(rez, sol[i]);

       g << rez << "\n";
   }
    return 0;
}