对于样例:
5 6
R F F F F F
F F F F F F
R R R F F F
F F F F F F
F F F F F F
正确输出应为45
可以下程序:
#include <bits/stdc++.h>
using namespace std;
class Hall
{
public:
int H,L;
};
stack<Hall> land;
int sum[1001][1001],S;
int main()
{
//玉蟾宫
char a;
int n,m,i,j,l;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
for(j=1;;)
{
a=getchar();
if (a==' ') continue;
if (a=='F') sum[i][j]=sum[i-1][j]+1,j++;
else if (a=='R') sum[i][j]=0,j++;
else break;
}
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
l=0;
while(!land.empty() && land.top().H>sum[i][j])
{
l+=land.top().L;
if (land.top().H*l>S) S=land.top().H*l;
land.pop();
}
land.push((Hall){sum[i][j],l+1});
}
l=0;
while(!land.empty())
{
l+=land.top().L;
if (land.top().H*l>S) S=land.top().H*l;
land.pop();
}
}
printf("%d",S*3);
}
(接下来是灵异事件)
Dev 输出为36
Luogu IDE 输出为18
而一交,A 了(