Pagini recente » Cod sursa (job #1253614) | Cod sursa (job #1952747) | Cod sursa (job #1623253) | Cod sursa (job #1773760) | Cod sursa (job #1517659)
#include <fstream>
#include <stdlib.h>
using namespace std;
ifstream cin("cutii.in");
ofstream cout("cutii.out");
struct nod { int a, b, c;} v[3502];
int n, t, x[3502];
int z( const void *i, const void *j)
{
nod *ei= (nod*)i,
*ej= (nod*)j;
if( ei->a != ej->a) return ej->a - ei->a;
if( ei->b != ej->b) return ej->b - ei->b;
return ej->c - ei->c;
}
void solve()
{
int MAX=0;
for(int i=1; i<=n; ++i) {
int max=0;
for(int j=i-1; j>=1; --j) if( v[j].b> v[i].b && v[j].c> v[i].c && x[j] > max) max=x[j];
max++;
x[i]= max;
if(max> MAX) MAX=max;
}
cout<<MAX<<'\n';
}
int main()
{
cin>>n>>t;
for(int i=1; i<=t; ++i) {
for(int j=1; j<=n; ++j) cin>>v[j].a>>v[j].b>>v[j].c;
qsort(v+1, n, sizeof(nod), z);
solve();
}
return 0;
}