【CSP试题回顾】202312-1-仓库规划

CSP-202312-1-仓库规划

解题代码

#include 
#include 
using namespace std;

int n, m;

int main() {
	cin >> n >> m;
	vector<vector<int>>posList(n, vector<int>(m));
	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = 0; j < m; j++)
		{
			cin >> posList[i][j];
		}
	}
	for (size_t i = 0; i < n; i++)
	{
		int index = -1;
		for (size_t j = 0; j < n; j++)
		{
			bool found = 1;
			for (size_t k = 0; k < m; k++)
			{
				if (posList[i][k] >= posList[j][k]) {
					found = 0;
					break;
				}
			}
			if (found)
			{
				index = j + 1;
				break;
			}
		}
		if (index == -1) cout << 0 << endl;
		else  cout << index << endl;
	}
	return 0;
}

请添加图片描述

你可能感兴趣的:(CSP备考,算法,c++)