题目:


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

int mt[1005][1005], H[1005][1005], L[1005][1005], R[1005][1005];
int main()
{
    int t;
    scanf("%d", &t);
    while(t--){

        memset(H, 0, sizeof(H));memset(L, 0, sizeof(L));memset(R, 0, sizeof(R));
        int n, m;
        scanf("%d%d", &n, &m);
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                int ch = getchar();
                while(ch!='F'&&ch!='R'){
                    ch = getchar();
                }
                mt[i][j]=ch=='F'?0:1;
            }
        }

        //初始化边界条件
        for(int i=0; i<n; i++){
            L[i][0]=0;
            R[i][m]=m-1;
        }
        for(int i=0; i<m; i++){
            L[0][i]=0;
        }

        int ans=0;
        for(int i=0; i<n; i++){
            int Lo=-1, Ro=m;

            for(int j=0; j<m; j++){//从左往右递推L数组
                if(mt[i][j]==1){//为阻碍
                    H[i][j]=L[i][j]=0; Lo=j;
                }
                else{           //F
                    H[i][j]=(i==0?1:H[i-1][j]+1);
                    L[i][j]=max(L[i][j], Lo+1);
                }
            }

            for(int j=m-1; j>=0; j--){//从右往左递推R数组
                if(mt[i][j]==1){
                    H[i][j]=0, R[i][j]=m-1; Ro=j;
                }
                else{
                    R[i][j]=min(R[i][j+1], Ro-1);
                    
                    ans=max(ans, H[i][j]*(R[i][j]-L[i][j]+1));//统计
                }
            }
        }
        printf("%d\n", ans);

    }

    return 0;
}
/* 10 5 5 FFRFF RRRRR FRFRF FRRRR FRRRR */