import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] oneLine = sc.nextLine().split(” “);
int hen = Integer.parseInt(oneLine[0]);
int su = Integer.parseInt(oneLine[1]);
int max = 0;
ArrayList[HTML_REMOVED] message = new ArrayList();
for (int i = 0; i < hen; i) {
String[] twoLine = sc.nextLine().split(” “);
message.add(twoLine);
}
int[][] dp = new int[hen][su];
for (int i = 0; i < dp.length; i) {
String[] onemessage = message.get(i);
for (int j = 0; j < dp[0].length; j++) {
if (i == 0) {
dp[i][j] = onemessage[j].equals(“R”) ? 0 : 1;
} else {
dp[i][j] = onemessage[j].equals(“R”) ? 0 : dp[i - 1][j] + 1;
}
}
max = Math.max(help(dp, i), max);
}
System.out.println(max);
}
public static int help(int[][] dp, int hen) {
int[] lineMessage = dp[hen];
Stack<Integer> stack = new Stack();
stack.push(0);
int p = 1, max = 0;
while (!stack.isEmpty()) {
if (p < lineMessage.length && lineMessage[p] >= lineMessage[stack.peek()]) {
stack.push(p);
p++;
} else {
int gao = lineMessage[stack.pop()];
int temp = stack.isEmpty() ? -1 : stack.peek();
int chang = p - temp-1 ;
max = Math.max(max, gao * chang);
// 栈空的情况
if (stack.isEmpty() && p < lineMessage.length) {
stack.push(p++);
}
}
}
return 3*max;
}
}
第一反应采用 dp ,结果做不出来
采用单调栈,
将每一行看作是 柱状图, 求柱状图面积的最大值.