P4147 玉蟾宫
一行没输入完就炸了
#include <bits/stdc++.h>
using namespace std;
int n,m,ans;
void find(int h[]){
int t[1010]={},s[1010]={},top,sop,l[1010]={},r[1010]={};
for(int i=1;i<=m;i++){
while(h[t[top]]>=h[i]&&top>=1)top--;
l[i]=t[top];
t[++top]=i;
}
for(int i=m;i>=1;i++){
while(h[s[sop]]>=h[i]&&sop>=1)sop--;
r[i]=m-s[sop]+1;
s[++sop]=i;
}
for(int i=1;i<=n;i++){
ans=max(ans,h[i]*(r[i]-l[i]-1));
}
return ;
}
char f[1010][1010];
int s[1010][1010];
int main(){
cin >> n >> m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >> f[i][j];
if(f[i][j]=='F'){
s[i][j]=s[i-1][j]+1;
}
}
find(s[i]);
}
cout << 3*ans;
return 0;
}