// 1<=n,m<=1000
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1005;
int a[MAXN][MAXN],ans1[MAXN][MAXN];
string s[MAXN][MAXN];
stack<int> st;
int main(){
int n,m;
cin >> n >> m;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++){
cin >> s[i][j];
if (s[i][j]=="F")
a[i][j]=a[i-1][j]+1;
}
int ans=0;
for (int i=1;i<=n;i++){
while (!st.empty()) st.pop();
for (int j=1;j<=m;j++){
if (s[i][j]=="R"){
while (!st.empty()) st.pop();
continue;
}
if (!st.empty() and st.top()<a[i][j]){while (!st.empty()) st.pop();}
st.push(a[i][j]);
ans1[i][j]=st.size();
}
}
for (int i=1;i<=n;i++){
while (!st.empty()) st.pop();
for (int j=m;j>=1;j--){
if (s[i][j]=="R"){
while (!st.empty()) st.pop();
continue;
}
if (!st.empty() and st.top()<a[i][j]){while (!st.empty()) st.pop();}
st.push(a[i][j]);
ans=max(ans,int(ans1[i][j]+st.size()-1)*a[i][j]);
}
}
cout << ans*3;
return 0;
}
思路:先用单调栈正着来一遍,算出每一个最多往前扩多少,再反着来一遍,同理(有一部分思路和第一篇题解相似)