Pagini recente » Cod sursa (job #2704984) | Cod sursa (job #1616175) | Cod sursa (job #1737403) | Cod sursa (job #1548721) | Cod sursa (job #2202669)
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#define NMAX 101
using namespace std;
ifstream fin("cutii.in");
ofstream fout("cutii.out");
struct date
{
int x,y,z,total;
};
vector < date > answer;
int N,M,BEST[NMAX],mx,T;
int compara(const date &a, const date &b)
{
return (a.total < b.total);
}
bool interior(const date &a, const date &b)
{
return (a.x < b.x && a.y < b.y && a.z < b.z);
}
int main()
{
fin>>N>>T;
for(int i =1; i <= T; i++)
{
for(int j = 1; j <= N; j++)
{
date c;
fin>>c.x>>c.y>>c.z;
c.total=c.x*100+c.y*10+c.z;
answer.push_back(c);
}
sort(answer.begin(), answer.end(), compara);
for(int j = 0 ; j < N; j++) BEST[j]=1;
for(int j = 1; j < N; j++)
for(int k = 0 ; k < j ; k++)
if(interior(answer[k],answer[j]) && BEST[k] >= BEST[j])
{
BEST[j]=BEST[k]+1;
mx=max(mx,BEST[j]);
}
fout<<mx<<'\n';
mx=0;
answer.clear();
}
}