Pagini recente » Cod sursa (job #2942495) | Cod sursa (job #1726342) | Cod sursa (job #143963) | Cod sursa (job #1526114) | Cod sursa (job #2843383)
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
ifstream cin("cutii.in");
ofstream cout("cutii.out");
class Info{
public:
int x;
int y;
int z;
};
bool cmp(Info a,Info b){
if(a.x==b.x){
if(a.y == b.y){
return a.z>b.z;
}
return a.y>b.y;
}
return a.x>b.x;
}
int n,t;
vector<Info> v;
vector<int> dp;
bool canPlace_A_In_B(Info a,Info b){
return a.x<b.x && a.y<b.y && a.z<b.z;
}
int howManyBoxes(){
fill(dp.begin()+1, dp.end(), 1);
for(int i=1;i<=n;i++){
for(int j=i-1;j>=1;j--){
if(canPlace_A_In_B(v[i],v[j])){
dp[j]=dp[j]+1;
}
else
break;
}
}
int rez=0;
for(int i=1;i<=n;i++){
rez=max(rez,dp[i]);
}
return rez;
}
void read(){
cin>>n>>t;
v.resize(n+1);
dp.resize(n+1);
for(int i=1;i<=t;i++){
for(int j=1;j<=n;j++){
cin>>v[j].x>>v[j].y>>v[j].z;
}
sort(v.begin()+1,v.end(),cmp);
cout<<howManyBoxes()<<'\n';
}
}
int main() {
read();
return 0;
}