古圣伦(((
  • 板块P4147 玉蟾宫
  • 楼主Lucifero
  • 当前回复1
  • 已保存回复1
  • 发布时间2020/12/28 20:07
  • 上次更新2023/11/5 05:33:43
查看原帖
古圣伦(((
335094
Lucifero楼主2020/12/28 20:07

对于样例:

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 了(

2020/12/28 20:07
加载中...