样例输入
4 2 0 0 -1 -1 1 2 0 -1
样例输出
3 1 0 3
代码:
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; int n, m; int a[1005][15]; int ans[1005]={0}; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { //第几个仓库 // int uu = 0; for (int j = 1; j <= n; j++) { //遍历所有仓库 int flag = 1; for (int z = 1; z <= m; z++) { //看是否都大于 if (a[i][z] >= a[j][z]) { flag = 0; break; } } if (flag == 1) { ans[i] = j; break; } } } for (int i = 1; i <= n; i++) { cout << ans[i] << endl; } }