Pagini recente » Cod sursa (job #1788519) | Cod sursa (job #19198) | Cod sursa (job #880187) | Cod sursa (job #1232883) | Cod sursa (job #1157249)
#include<cstdio>
#define M -2000000000
#include<algorithm>
#include<cstring>
using namespace std;
FILE *f=fopen("cutii.in","r");
FILE *g=fopen("cutii.out","w");
struct cut
{
int x,y,z;
};
cut L[3501];
int aux[3501],perm[3501],nr,n,k,maxim;
int cmp(cut a,cut b)
{
if(a.x>b.x&&a.y>b.y&&a.z>b.z)return 1;
return 0;
}
bool cmp1(int a,int b)
{
if(L[a].x>L[b].x)return false;
else
{
if(L[a].x==L[b].x)
{
if(L[a].y>L[b].y) return false;
else
{
if(L[a].y==L[b].y)
{
if(L[a].z>L[b].z) return false;
else return true;
}
}
}
}
}
int scm()
{
int i,j;
int maxx;
maxx=M;
for(i=1;i<=k;i++)
{
aux[perm[i]]=1;
for(j=i-1;j>=1;j--)
if(cmp(L[perm[i]],L[perm[j]])&&aux[perm[j]]>aux[perm[i]]-1)
{
aux[perm[i]]=aux[perm[j]]+1;
}
if(aux[perm[i]]>maxx)maxx=aux[perm[i]];
}
fprintf(g,"%d\n",maxx);
}
int main()
{
int i,i1,j,maxx;
fscanf(f,"%d%d",&k,&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=k;j++)
{
nr++;
fscanf(f,"%d%d%d",&L[j].x,&L[j].y,&L[j].z);
}
for(i1=1;i1<=k;i1++)perm[i1]=i1;
sort(perm+1,perm+k+1,cmp1);
scm();
}
return 0;
}