Cod sursa(job #2777917)

Utilizator AsandeiStefanAsandei Stefan-Alexandru AsandeiStefan Data 26 septembrie 2021 09:12:43
Problema Cutii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.09 kb
#include <fstream>
#include <vector>
#include <algorithm>

std::ifstream fin("cutii.in");
std::ofstream fout("cutii.out");

struct cutie
{
	int x;
	int y;
	int z;
	int nrCutiiCarePotIntra;

	bool operator< (const cutie& other) const 
	{
		return (this->x < other.x &&
			this->y < other.y &&
			this->z < other.z) || ((this->x+this->y+this->z) / 3) < ((other.x + other.y + other.z) / 3);
	}
};

int n, t, i;
std::vector<std::vector<cutie>> cutii;

int dp(int currentIndex)
{
	if (currentIndex == 0)
		return 0;

	if (cutii[i][currentIndex-1] < cutii[i][currentIndex])
		cutii[i][currentIndex].nrCutiiCarePotIntra = dp(currentIndex - 1) + 1;
	else cutii[i][currentIndex].nrCutiiCarePotIntra = 0;

	return cutii[i][currentIndex].nrCutiiCarePotIntra;
}

int main()
{
	fin >> n >> t;
	cutii = std::vector<std::vector<cutie>>(t, std::vector<cutie>(n));
	for (i = 0; i < t; i++)
	{
		for (int j = 0; j < n; j++)
		{
			fin >> cutii[i][j].x >> cutii[i][j].y >> cutii[i][j].z;
		}
		std::sort(cutii[i].begin(), cutii[i].end());
		fout << dp(n-1)+1 << '\n';
	}
	return 0;
}