Pagini recente » Atasamentele paginii petic | Borderou de evaluare (job #242606) | Rezultatele filtrării | Cod sursa (job #958360) | Cod sursa (job #2938369)
//#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
//dp[i] = nr. max. de cutii ce pot fi alese cu cutia i fiind ultima
//dp[i] = 1 + max(dp[j]), cu dimensiunile cutii lui j mai mari ca ale lui i
int dp[3504];
struct cub
{
int x, y, z;
} v[3504];
bool operator <(cub a, cub b) //a < b <=>
{
/* if (a.x != b.x)
return a.x > b.x;
if (a.y != b.y)
return a.y > b.y;
return a.z > b.z;*/
return a.x > b.x and a.y > b.y and a.z > b.z;
}
bool cmp(cub a, cub b)
{
if (a.x != b.x)
return a.x > b.x;
if (a.y != b.y)
return a.y > b.y;
return a.z > b.z;
}
vector <cub> aux;
int main()
{
ifstream cin("cutii.in");
ofstream cout("cutii.out");
int n, t, i, j;
cin >> n >> t;
while (t--)
{
for (i = 1; i <= n; i++)
{
cin >> v[i].x >> v[i].y >> v[i].z;
}
sort(v + 1, v + n + 1, cmp);
for (i = 1; i <= n; i++)
{
//cout << v[i].x << " " << v[i].y << " " << v[i].z << "\n";
auto it = lower_bound(aux.begin(), aux.end(), v[i]);
if (it == aux.end())
aux.push_back(v[i]);
else
{
bool x = (it->x < v[i].x);
bool y = (it->y < v[i].y);
bool z = (it->z < v[i].z);
int cnt = x + y + z;
if (cnt > 0)
*it = v[i];
}
}
cout << aux.size() << "\n";
aux.clear();
}
}