悬线法
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int n, m, ans=0, h[1005][1005], l[1005][1005], r[1005][1005];
bool a[1005][1005];
char s[15];
int main(){
cin>>n>>m;
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++){
scanf("%s", s);
a[i][j] = s[0]==‘F‘;
}
for(int i=1; i<=n; i++){
int x=1;
for(int j=1; j<=m; j++)
if(a[i][j]) l[i][j] = x;
else l[i][j] = 1, x = j + 1;
x = m;
for(int j=m; j>=1; j--)
if(a[i][j]) r[i][j] = x;
else r[i][j] = m, x = j - 1;
}
for(int i=1; i<=m; i++) l[0][i] = 1, r[0][i] = m;
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
if(a[i][j]){
h[i][j] = h[i-1][j] + 1;
l[i][j] = max(l[i][j], l[i-1][j]);
r[i][j] = min(r[i][j], r[i-1][j]);
ans = max(ans, (r[i][j]-l[i][j]+1)*h[i][j]);
}
cout<<ans*3<<endl;
return 0;
}