AcWing 5415. 仓库规划
原题链接
简单
作者:
不知名的fE
,
2024-11-30 16:24:19
,
所有人可见
,
阅读 3
暴力枚举O(n^2 * m)够用
import java.util.*;
import java.io.*;
public class Main {
static final int N = 1010, M = 12;
static int[][] arr = new int[N][M];
static int n, m;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
String[] read = br.readLine().split(" ");
n = Integer.parseInt(read[0]); m = Integer.parseInt(read[1]);
for (int i = 1; i <= n; i++) {
arr[i] = toInt(br.readLine().split(" "));
}
for (int i = 1; i <= n; i++) {
boolean flag1 = true;
int[] t = arr[i];
for (int j = 1; j <= n; j++) {
boolean flag2 = true;
for (int k = 1; k <= m; k++) {
if (t[k] >= arr[j][k]) {
flag2 = false;
break;
}
}
if (flag2) {
out.println(j);
flag1 = false;
break;
}
}
if (flag1) out.println(0);
}
out.flush();
}
static int[] toInt(String[] str) {
int[] res = new int[M];
for (int i = 1; i <= m; i++) res[i] = Integer.parseInt(str[i - 1]);
return res;
}
}