//
// main.cpp
// Richard
//
// Created by 邵金杰 on 16/10/1.
// Mail:1016427040@qq.com or jasonshaosjj@gmail.com
// Copyright © 2016年 邵金杰. All rights reserved.
//
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1000+10;
int h[maxn][maxn],l[maxn],r[maxn];
char map[maxn][maxn];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
memset(h,0,sizeof(h));
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char ch=getchar();
while(ch!='R'&&ch!='F') ch=getchar();
h[i][j]=(ch=='F')?h[i-1][j]+1:0;
}
}
int ans=0;
for(int i=1;i<=n;i++){
l[1]=1;r[m]=m;
for(int j=2;j<=m;j++){
int t=j;
while(t>1&&h[i][j]<=h[i][t-1]) t=l[t-1];
l[j]=t;
}
for(int j=m-1;j>=1;j--){
int t=j;
while(t<m&&h[i][j]<=h[i][t+1]) t=r[t+1];
r[j]=t;
}
for(int j=1;j<=m;j++) ans=max(ans,(r[j]-l[j]+1)*h[i][j]);
}
cout<<ans*3<<endl;
}
return 0;
}
UVA 1330 City Game(最大子矩阵)
最新推荐文章于 2018-09-29 18:26:05 发布