Pagini recente » Cod sursa (job #2114246) | Cod sursa (job #5157) | Cod sursa (job #1610833) | Cod sursa (job #943835) | Cod sursa (job #2312543)
#include <bits/stdc++.h>
using namespace std;
const int NR = 3501 ;
ifstream f ("cutii.in") ;
ofstream g ("cutii.out") ;
struct el
{int x, y ,z ;
}v [ NR ];
bool cmp ( el a , el b )
{
if ( a.x == b.x )
{
if ( a.y == b.y ) return a.z < b.z ;
return a.y < b.y ;
}
return a.x < b.x ;
}
int main ()
{
int n , t ; f >> n >> t ;
while ( t -- )
{
int maxim = 1 ;
for ( int i = 1 ; i <= n ; ++ i ) f >> v [ i ].x >> v [ i ].y >> v [ i ].z ;
sort ( v + 1 , v + n + 1 , cmp ) ;
vector < int > q ( n + 1 , 1 ) ;
for ( int i = 1 ; i < n ; ++ i )
for ( int j = i + 1 ; j <= n ; ++ j )
{
if ( v [ i ].x < v [ j ].x && v [ i ].y < v [ j ].y && v [ i ].z < v [ j ].z && q [ i ] + 1 > q [ j ] )
{
q [ j ] = q [ i ] + 1 ;
if ( q [ j ] > maxim ) maxim = q [ j ] ;
}
}
g << maxim << "\n" ;
}
}