#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m;
int mat[1010][1010],leftt[1010][1010],rightt[1010][1010],high[1010][1010];
int max(int a,int b)
{
if(a>b)
return a;
return b;
}
int min(int a,int b)
{
if(a>b)
return b;
return a;
}
int solve()
{
int i,j;
int ans=0;
for(i=1;i<=n;i++){
int leftnum=0;
for(j=1;j<=m;j++){
if(mat[i][j]==0)
{
leftnum=j;
leftt[i][j]=0;
high[i][j]=0;
}
else
{
leftt[i][j]=i==1?leftnum+1:max(leftt[i-1][j],leftnum+1);
high[i][j]=i==1?1:high[i-1][j]+1;
}
}
int rightnum=m+1;
for(j=m;j>=1;j--){
if(mat[i][j]==0){
rightnum=j;
rightt[i][j]=m+1;
}
else
{
rightt[i][j]=i==1?rightnum-1:min(rightt[i-1][j],rightnum-1);
ans=max(ans,high[i][j]*(rightt[i][j]-leftt[i][j]+1));
}
}
}
return 3*ans;
}
int main()
{
int t;
cin>>t;
while(t--)
{
scanf("%d%d",&n,&m);
int i,j;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++){
char c=getchar();
while(c!='F'&&c!='R')
c=getchar();
mat[i][j]=c=='F'?1:0;
}
printf("%d\n",solve());
}
return 0;
}
uva1330
最新推荐文章于 2018-09-29 18:26:05 发布