Pagini recente » Cod sursa (job #1864694) | Monitorul de evaluare | Cod sursa (job #1246989) | Cod sursa (job #981640) | Cod sursa (job #2686476)
#include <fstream>
#include <algorithm>
#define NMAX 3510
using namespace std;
ifstream f("cutii.in");
ofstream g("cutii.out");
struct cutie
{
int x, y, z;
}v[NMAX];
int n, q, dp[NMAX];
bool comp(cutie x, cutie y)
{
return x.x > y.x;
}
bool intra(cutie x, cutie y)
{
return (x.x < y.x && x.y < y.y && x.z < y.z);
}
int main()
{
f >> n >> q;
while(q--)
{
int mx = 0;
for (int i=1; i<=n; i++)
f >> v[i].x >> v[i].y >> v[i].z;
sort(v+1, v+1+n, comp);
/*for (int i=1; i<=n; i++)
g << v[i].x << v[i].y << v[i].z << '\n';*/
for (int i=1; i<=n; i++)
{
int w = 0;
for (int j=i; j>=1; j--)
if (intra(v[i], v[j]))
if (w < dp[j]+1) w = dp[j]+1;
dp[i] = max(w, 1);
if (dp[i] > mx) mx = dp[i];
}
g << mx << '\n';
}
}