全新版本(洛谷,ACGO通用)
2025-08-04 17:00:49
发布于:上海
8阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
long long a[N][N],dp[N][N];
char grid[N][N];
int n,m;
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>grid[i][j];
if(grid[i][j]=='F')dp[i][j]=dp[i-1][j]+1;
else dp[i][j]=0;
}
}
int ans=0;
stack<int>st;
for(int i=1;i<=n;i++){
for(int j=1;j<=m+1;j++){
while(!st.empty()&&dp[i][st.top()]>dp[i][j]){
int idx=st.top();
st.pop();
int width;
if(st.empty())width=j-1;
else width=j-st.top()-1;
int area=dp[i][idx]*width;
if(area>ans)ans=area;
}
st.push(j);
}
while(st.size()){
st.pop();
}
}
cout<<ans*3;
return 0;
}
ACGO样例终究是太水了
这里空空如也
有帮助,赞一个