Pagini recente » Cod sursa (job #1650948) | Cod sursa (job #237927) | Cod sursa (job #1201158) | Cod sursa (job #2526110) | Cod sursa (job #655839)
Cod sursa(job #655839)
#include <fstream>
#include <algorithm>
#define nmax 3501
#define x first
#define y second
using namespace std;
inline bool cmp(pair<int, pair<int,int> > a, pair<int, pair<int,int> > b){
return a.y.y < b.y.y;
}
int l[nmax];
int n, t;
pair<int, pair<int,int> > v[nmax];
ifstream f("cutii.in");
ofstream g("cutii.out");
void citeste(){
f>>n>>t;
}
void cit(){
for(int i=1; i<=n; ++i){
int x,y,z;
f>>x>>y>>z;
v[i] = make_pair(x,make_pair(y,z));
}
sort(v+1,v+n+1, cmp);
}
void rezolva(){
int mx = 0;
for(int i=0; i<=n; ++i) l[i] = 0;
l[n] = 1;
int mx2 = 1;
for(int i=n-1; i>=1; i--){
for(int j=i+1; j<=n; ++j)
if (v[j].x > v[i].x && v[j].y.x > v[i].y.x && v[j].y.y > v[i].y.y && mx < l[j] ) mx = l[j];
l[i] = mx + 1;
if (mx2 < l[i]) mx2 = l[i];
}
g<<mx2<<"\n";
}
void rez(){
for(int i=1; i<=t; ++i){
cit();
rezolva();
}
}
int main(){
citeste();
rez();
f.close();
g.close();
return 0;
}