Pagini recente » Cod sursa (job #1996264) | Cod sursa (job #2030491) | Cod sursa (job #1021168) | Cod sursa (job #289596) | Cod sursa (job #442695)
Cod sursa(job #442695)
#include<cstdio>
#include<algorithm>
using namespace std;
struct cub
{
int x,y,z;
};
cub a[1<<12];
int n,t,v[1<<12];
bool comp(const cub &A,const cub &B)
{
if(A.x>B.x) return false;
if(A.x<B.x) return true;
if(A.y>B.y) return false;
if(A.y<B.y) return true;
if(A.z>B.z) return false;
if(A.z<B.z) return true;
return true;
}
int cautb(int poz)
{
int i=0,pas=1<<12;
for(i=0;pas;pas>>=1)
if(i+pas<=v[0] && a[v[i+pas]].x<a[poz].x && a[v[i+pas]].y<a[poz].y && a[v[i+pas]].z<a[poz].z)
i+=pas;
return i+1;
}
int main()
{
freopen("cutii.in","r",stdin);
freopen("cutii.out","w",stdout);
scanf("%d%d",&n,&t);
for(;t>=1;t--)
{
for(int i=1;i<=n;i++)
scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
sort(a+1,a+n+1,comp);
v[0]=1;
v[1]=1;
for(int i=2;i<=n;i++)
{
int j=cautb(i);
if(j>v[0])
++v[0];
v[j]=i;
}
printf("%d\n",v[0]);
}
return 0;
}