Pagini recente » Cod sursa (job #2109490) | Cod sursa (job #1774824) | Cod sursa (job #412059) | Cod sursa (job #2493472) | Cod sursa (job #1327530)
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ifstream f("cutii.in");
ofstream g("cutii.out");
const int NMAX = 3500 + 5;
struct cutie{
int x,y,z;
}c[NMAX];
int N,T;
int v[NMAX];
inline int cmp(cutie A,cutie B)
{
if (A.x == B.x)
{
if (A.y == B.y)
{
if (A.z < B.z) return A.z < B.z;
}
else
{
if (A.y < B.y) return A.y < B.y;
}
}
else
{
if (A.x < B.x) return A.x < B.x;
}
}
int main()
{
// ios_base::sync_with_stdio(0);
f >> N >> T;
c[0].x = NMAX; c[0].y = NMAX; c[0].z = NMAX;
for (int k = 0; k < T; k++)
{
for (int i = 1; i <= N ; i++)
{
f >> c[i].x >> c[i].y >> c[i].z;
v[i] = 0;
}
sort(c+1,c+N+1,cmp);
int res = 0;
v[0] = 1;
/* for (int i = 1; i <= N ; i++)
cout << c[i].x << ' ' << c[i].y << ' ' << c[i].z << '\n';
*/
for (int i = 1; i <= N ; i++)
{
for (int j = i - 1; j >= 0; j--)
{
if (v[j] && v[j] + 1 > v[i] )
{
if (c[j].x > c[i].x && c[j].y > c[i].y && c[j].z > c[i].z )
{
v[i] = v[j] + 1 ;
res = max(res,v[i]);
}
}
}
}
/*for (int i = 1; i <= N ; i++)
{
cout << v[i] << ' ';
}
cout << '\n';*/
g << res - 1 << '\n';
}
return 0;
}