悬线法 || BZOJ3039: 玉蟾宫 || Luogu P4147 玉蟾宫

时间:2023-02-04 02:35:33

题面: P4147 玉蟾宫

题解:过于板子举报了

 #include<cstdio>
#include<cstring>
#include<iostream>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
using namespace std;
const int maxn=,maxm=maxn;
int N,M,L[maxn][maxm],R[maxn][maxm],H[maxn][maxm],ans=;
char c,C[maxn][maxm];
int main(){
scanf("%d%d",&N,&M);
for(int i=;i<=N;i++){
for(int j=;j<=M;j++){
c=getchar();
while(c!='R'&&c!='F')c=getchar();
C[i][j]=c;
}
}
for(int i=;i<=N;i++){
for(int j=;j<=M;j++){
if(C[i][j]=='F')H[i][j]=H[i-][j]+;
else H[i][j]=;
if(C[i][j]=='F')L[i][j]=L[i][j-]+;
else L[i][j]=;
int r=M-j+;
if(C[i][r]=='F')R[i][r]=R[i][r+]+;
else R[i][r]=;
}
}
for(int i=;i<=N;i++){
for(int j=;j<=M;j++){
if(H[i][j]>){
L[i][j]=min(L[i][j],L[i-][j]);
R[i][j]=min(R[i][j],R[i-][j]);
}
ans=max(ans,(L[i][j]+R[i][j]-)*H[i][j]);
}
}
ans*=;
printf("%d\n",ans);
return ;
}

By:AlenaNuna