Pagini recente » Cod sursa (job #1358679) | Cod sursa (job #2766308) | Cod sursa (job #926294) | Cod sursa (job #1534989) | Cod sursa (job #2689416)
#include <algorithm>
#include <fstream>
#include <cstring>
#define fq 3502
using namespace std;
ifstream fin("cutii.in");
ofstream fout("cutii.out");
int n,t,i,j;
int dp[fq],maxi;
struct box{
int x,y,z;
bool operator< (const box t) const{
if(x<t.x)
return true;
else if(x==t.x)
{
if (y<t.y)
return true;
else if(y==t.y && z<t.z)
return true;
}
return false;
}
}v[fq];
bool compare(box a,box b){
return a.x>b.x && a.y>b.y && a.z>b.z;
}
int main()
{
fin>>n>>t;
while(t)
{
for(i=1; i<=n; i++)
fin>>v[i].x>>v[i].y>>v[i].z;
sort(v+1,v+n+1);
memset(dp,0,sizeof(dp));
dp[n]=1, maxi=0;
for(i=n-1; i>=1; i--)
{
for(j=i+1; j<=n; j++)
if(compare(v[j],v[i]) && dp[j]>maxi)
maxi=dp[j];
dp[i]=maxi+1;
maxi=0;
}
for(i=1; i<=n; i++)
maxi=max(maxi,dp[i]);
fout<<maxi<<'\n', t--;
}
return 0;
}