Pagini recente » Cod sursa (job #2012480) | Cod sursa (job #1999034) | Istoria paginii utilizator/falicos | Cod sursa (job #1992871) | Cod sursa (job #834843)
Cod sursa(job #834843)
#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
using namespace std;
struct p{
int a, b, c;
};
p dp[3505],v[3505];
bool intra(p cutie,p dest)
{
return (cutie.a<dest.a && cutie.b<dest.b && cutie.c<dest.c);
}
struct cmp
{
bool operator()(const p &x , const p &y)
{
if(x.a==y.a)
{
if(x.b==y.b)
return x.c<y.c;
else
return x.b<y.b;
}
return x.a<y.a;
}
};
int main()
{
int n,t;
ifstream f("cutii.in");
ofstream g("cutii.out");
f>>n>>t;
for(int i=1;i<=t;i++)
{
memset(dp,0,sizeof(dp));
int sz=0;
for(int j=1;j<=n;j++)
f>>v[j].a>>v[j].b>>v[j].c;
sort(v+1,v+n+1,cmp());
for(int j=1;j<=n;j++)
{
for(int k=sz;k>=0;k--)
if(intra(dp[k],v[j]))
{
if(k+1>sz)
{
++sz;
dp[k+1]=v[j];
}
else
if(dp[k+1].a<=v[j].a && dp[k+1].b<=v[j].b && dp[k+1].c<=v[j].c)
dp[k+1]=v[j];
break;
}
}
g<<sz<<"\n";
}
return 0;
}