Pagini recente » Cod sursa (job #327663) | Cod sursa (job #1518407) | Cod sursa (job #3248535) | Cod sursa (job #484221) | Cod sursa (job #479254)
Cod sursa(job #479254)
# include <fstream>
# include <vector>
# include <algorithm>
using namespace std;
struct dim{
int x, y, z;
dim(){}
dim(int X, int Y, int Z){
x=X;y=Y;z=Z;}
friend bool operator < (const dim &a, const dim &b){
if (a.x<b.x && a.y<b.y && a.z<b.z)return 1;
return 0;
}
};
int n, t, l[3505];
vector<dim>V[105];
void read ()
{
ifstream fin ("cutii.in");
int x, y, z;
fin>>n>>t;
for(int i=1;i<=t;++i)
for(int j=1;j<=n;++j)
{
fin>>x>>y>>z;
V[i].push_back(dim(x, y, z));
}
}
int main ()
{
ofstream fout ("cutii.out");
int max;
read ();
for(int k=1;k<=t;++k)
{
for(int i=0;i<=n;++i)
l[i]=1;
max=0;
sort(V[k].begin(),V[k].end());
for(int i=1;i<n;++i)
for(int j=i-1;j>=0;--j)
if (l[j]+1>l[i] && V[k][j]<V[k][i])
{
l[i]=l[j]+1;
if(l[i]>max)
max=l[i];
}
fout<<max<<"\n";
}
return 0;
}