Pagini recente » Cod sursa (job #1680376) | Cod sursa (job #1297988) | Statistici enache madalina (mada_blondootza) | Cod sursa (job #2104952) | Cod sursa (job #1770136)
#include <algorithm>
#include <fstream>
#include <tuple>
#include <vector>
using namespace std;
typedef tuple<int, int, int> Cutie;
bool CmpCutii(const Cutie &a, const Cutie &b)
{
return get<0>(a) > get<0>(b);
}
bool Incape(const Cutie &ma, const Cutie &mi)
{
return get<1>(ma) > get<1>(mi) && get<2>(ma) > get<2>(mi);
}
int main()
{
ifstream fin("cutii.in");
ofstream fout("cutii.out");
int n, t;
fin >> n >> t;
vector<Cutie> cutii(n + 1);
vector<int> lmax(n + 1);
vector<vector<int>> pozitii(n + 1);
while (t--) {
for (int i = 1; i <= n; ++i)
fin >> get<0>(cutii[i]) >> get<1>(cutii[i]) >> get<2>(cutii[i]);
sort(cutii.begin() + 1, cutii.end(), CmpCutii);
fill(lmax.begin() + 1, lmax.end(), 1);
fill(pozitii.begin() + 1, pozitii.end(), vector<int>());
int rezultat = 0;
for (int i = 1; i <= n; ++i) {
for (int j = rezultat; j > 0 && lmax[i] == 1; --j) {
for (int poz : pozitii[j]) {
if (Incape(cutii[poz], cutii[i])) {
lmax[i] = j + 1;
break;
}
}
}
pozitii[lmax[i]].push_back(i);
rezultat = max(rezultat, lmax[i]);
}
fout << rezultat << "\n";
}
return 0;
}