Pagini recente » Cod sursa (job #763396) | Cod sursa (job #623138) | Cod sursa (job #2449214) | Cod sursa (job #2664826) | Cod sursa (job #719031)
Cod sursa(job #719031)
#include<fstream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MaxN = 3501;
const char InFile[] = "cutii.in";
const char OutFile[] = "cutii.out";
int N,T,Best,bst[MaxN];
struct box
{
int x,y,z;
}Box[MaxN];
ifstream fin( InFile );
ofstream fout( OutFile );
bool cmp( box a , box b )
{
return a.z < b.z;
}
void read()
{
for( int i = 1 ; i <= N ; ++i )
fin >> Box[i].x >> Box[i].y >> Box[i].z;
}
void solve()
{
Best = 0;
memset(bst,0,sizeof(bst));
int i,j;
bst[N] = 1;
for( i = N-1 ; i ; --i )
{
bst[i] = 1;
for( j = i+1 ; j <= N ; ++j )
if( Box[i].x < Box[j].x && Box[i].y < Box[j].y && Box[i].z < Box[j].z && bst[i] < bst[j] + 1 )
{
bst[i] = bst[j] + 1;
if( bst[i] > Best )
Best = bst[i];
}
}
}
int main()
{
fin >> N >> T;
for( ; T ; --T )
{
read();
sort(Box+1,Box+N+1,cmp);
solve();
fout << Best << '\n';
}
fin.close();fout.close();
return 0;
}