Pagini recente » Cod sursa (job #3131974) | Cod sursa (job #1122896) | Cod sursa (job #2782310) | Cod sursa (job #1255776) | Cod sursa (job #2412560)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("cutii.in");
ofstream g("cutii.out");
struct cut{
int x, y, z;
}cutii[3505];
bool operator<(cut a, cut b)
{
if (a.x==b.x && a.y==b.y)
return a.z>b.z;
if (a.x==b.x)
return a.y>b.y;
return a.x>b.x;
}
int dp[3505], n, t, maxi;
void citire(int ind)
{
f >> cutii[ind].x >> cutii[ind].y >> cutii[ind].z;
dp[ind]=0;
}
bool e_bine(cut a, cut b)
{
if (b.x>a.x && b.y>a.y && b.z>a.z)
return true;
return false;
}
void solve()
{
dp[1]=1;
for (int i=2; i<=n; ++i)
{
for (int j=i-1; j>0; --j)
{
if (dp[j]+1>dp[i] && e_bine(cutii[i],cutii[j]))
{
dp[i]=dp[j]+1;
maxi=max(maxi,dp[i]);
}
}
}
}
int main() {
f >> n >> t;
for (int test=1; test<=t; ++test)
{
for (int i=1; i<=n; ++i)
{
citire(i);
}
maxi=0;
sort(cutii+1,cutii+n+1);
solve();
g << maxi << '\n';
}
return 0;
}