Cod sursa(job #2938369)

Utilizator AswVwsACamburu Luca AswVwsA Data 11 noiembrie 2022 23:56:06
Problema Cutii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.61 kb
//#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();
    }
}