P4147 玉蟾宫(悬线法)

 

P4147 玉蟾宫

 

#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e3 + 10;

int n,m;
int a[maxn][maxn] = {{0,0}};
int l[maxn][maxn],r[maxn][maxn],h[maxn][maxn];
int ans;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char ch;cin >>ch;
            if(ch == 'F') {
                a[i][j] = 1;
                h[i][j] = h[i - 1][j] + 1;
                l[i][j] = l[i][j - 1] + 1;
            }
        }
        for(int j = m; j >= 1; j--){
            if(a[i][j]){
                r[i][j] = r[i][j + 1] + 1;
            }
        }
    } 
    for(int i = 1; i <= n; i++){
        for(int j = 2; j <= m; j++){
            if(i >= 2 && a[i][j] && a[i - 1][j]){
                l[i][j] = min(l[i][j],l[i - 1][j]);
                r[i][j] = min(r[i][j],r[i - 1][j]);
            }
            ans = max(ans,h[i][j] *(l[i][j] + r[i][j] - 1));
        }
    } 
    
    cout << 3 * ans <<endl;
    return 0;
} 
View Code

 

posted @ 2025-09-18 10:56  Hazelxcf  阅读(2)  评论(0)    收藏  举报