1 #include <stdio.h>
2 #include <string.h>
3 #include <math.h>
4 #define MAXSIZE 1005
5 int dp[MAXSIZE][MAXSIZE];
6 int l[MAXSIZE][MAXSIZE],r[MAXSIZE][MAXSIZE];
7 bool scan(char &ch){
8 while (ch=getchar()){
9 if(ch=='R')
10 return false;
11 else if(ch=='F')
12 return true;
13 }
14 }
15 int main(){
16 //freopen("in.txt","r",stdin);
17 int t;
18 scanf("%d",&t);
19 while (t--){
20 int m,n;//行、列
21 scanf("%d%d",&m,&n);
22 memset(dp,0,sizeof(dp));
23 int i,j;
24 char ch;
25 for(i=1;i<=m;i++)
26 for(j=1;j<=n;j++)
27 if(scan(ch))
28 dp[i][j]=dp[i-1][j]+1;
29 int maxs=-1;
30 for(i=1;i<=m;i++){
31 dp[i][0]=dp[i][n+1]=-1;
32 for(j=1;j<=n;j++)
33 l[i][j]=r[i][j]=j;
34 for(j=2;j<=n;j++)
35 while (dp[i][l[i][j]-1]>=dp[i][j])
36 l[i][j]=l[i][l[i][j]-1];
37 for(j=n-1;j>=1;j--)
38 while (dp[i][r[i][j]+1]>=dp[i][j])
39 r[i][j]=r[i][r[i][j]+1];
40 for(j=1;j<=n;j++)
41 if(dp[i][j]*(r[i][j]-l[i][j]+1)>maxs)
42 maxs=dp[i][j]*(r[i][j]-l[i][j]+1);
43 }
44 printf("%d\n",maxs*3);
45 }
46 return 0;
47 }
48
posted on 2012-05-14 23:56
Leo.W 阅读(256)
评论(0) 编辑 收藏 引用