求救(玄关)
查看原帖
求救(玄关)
1124466
Tommyshizichen楼主2024/6/15 15:24
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int n,m,ans,h[N][N],f1[N],f2[N];
char a;
void calc(int x){
	stack<int> s;
	for(int i=1;i<=m;i++){
		while(!s.empty()&&h[x][s.top()]>=h[x][i]){
			s.pop(); 
		}
		f1[i]=s.empty() ? 0 : s.top();
		s.push(i);
	}
	stack<int> s1;
	for(int i=m;i>=1;i--){
		while(!s1.empty()&&h[x][s1.top()]>=h[x][i]){
			s1.pop(); 
		}
		f2[i]=s1.empty() ? 0 : s1.top();
		s1.push(i);
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a;
			if(a=='F') h[i][j]=h[i-1][j]+1;
		}
	}
	for(int i=1;i<=n;i++){
		calc(i);
		for(int j=1;j<=m;j++){
			int left=(f1[i]==0 ?1:(f1[j]+1) );
			int right=(f2[i]==0 ?m:(f2[j]-1) );
			ans=max(ans,h[i][j]*(right-left+1));
		}
	}
	cout<<ans*3;

	return 0;
}
2024/6/15 15:24
加载中...