Pagini recente » Cod sursa (job #2291102) | Cod sursa (job #323340) | Cod sursa (job #712629) | Cod sursa (job #2358497) | Cod sursa (job #1200648)
#include <fstream>
#include <cstring>
#include <algorithm>
using namespace std;
#define dim 10505
struct D{int x,y,z;};
struct comp{
bool operator()(const D &a,const D &b){
return a.x < b.x;
}
};
D a[dim];
int best[dim];
int main(){
ifstream f("cutii.in");
ofstream g("cutii.out");
int n,t,i,j;
f >> n >> t;
while(t--){
int BestC=0;
memset(best,0,sizeof(best));
for(i=1;i<=n;i++)
f >> a[i].x >> a[i].y >> a[i].z;
sort(a+1,a+n+1,comp());
for(i=n-1;i>=1;i--){
if(a[i].x==n || a[i].y==n || a[i].z==n) continue;
for(j=n;j>i;j--){
if(a[j].y>a[i].y && a[j].z>a[i].z && best[i]<best[j]+1){
best[i]=best[j]+1;
}
}
BestC=max(BestC,best[i]);
}
g << BestC+1 << "\n";
}
}