Pagini recente » Cod sursa (job #3293258) | Cod sursa (job #2000305) | Cod sursa (job #1544195) | Cod sursa (job #1736358) | Cod sursa (job #1050652)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream is("cutii.in");
ofstream os("cutii.out");
struct ceva{
int x, y, z;
}c[3500];
int d[3500];
int n, t;
int maxim;
bool COMP(const ceva& a, const ceva& b);
bool OK(ceva a, ceva b);
int main()
{
is >> n >> t;
for ( int k = 1; k <= t; ++k )
{
for ( int j = 1; j <= n; ++j )
is >> c[j].x >> c[j].y >> c[j].z;
sort(c + 1, c + n + 1, COMP);
//for ( int j = 1; j <= n; ++j )
//os << c[j].x << " " << c[j].y << " " << c[j].z << "\n";
maxim = 0;
for ( int i = 1; i <= n; ++i )
{
d[i] = 1;
for ( int j = 1; j < i; ++j )
{
if ( OK(c[j], c[i]) && d[j] + 1 > d[i] )
d[i] = d[j] + 1;
if ( d[i] > maxim )
maxim = d[i];
}
}
os << maxim << "\n";
}
is.close();
os.close();
return 0;
}
bool COMP(const ceva& a, const ceva& b)
//bool COMP(const int& a, const int& b)
{
if ( a.x < b.x )
return true;
if ( a.x > b.x )
return false;
if ( a.y < b.y )
return true;
if ( a.y > b.y )
return false;
if ( a.z > b.z )
return false;
return true;
}
bool OK(ceva a, ceva b)
{
if ( a.x < b.x && a.y < b.y && a.z < b.z )
return true;
return false;
}