求助
  • 板块灌水区
  • 楼主liuergou
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/3/10 11:45
  • 上次更新2024/3/10 14:41:47
查看原帖
求助
722656
liuergou楼主2024/3/10 11:45

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;
}

2024/3/10 11:45
加载中...