题目地址:http://vjudge.net/problem/UVALive-3029
第二次写
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<=(b);++i)
#define REPD(i,a,b) for(int i=a;i>=(b);--i)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
const int maxn=1000+3;
int mat[maxn][maxn],Left[maxn][maxn],Right[maxn][maxn],up[maxn][maxn];
int main(int argc, char const *argv[])
{int T; scanf("%d",&T);while(T--){int R,C; scanf("%d%d",&R,&C);REP(i,1,R) REP(j,1,C) {char ch; do{ch=getchar();}while(ch!='F'&&ch!='R');mat[i][j]= ch=='R';}int ans=0;REP(i,1,R) {int lo=0,ro=C+1;REP(j,1,C)if(mat[i][j]) up[i][j]=Left[i][j]=0,lo=j;else up[i][j]=up[i-1][j]+1,Left[i][j]= i==1?lo+1:max(Left[i-1][j],lo+1);REPD(j,C,1)if(mat[i][j]) Right[i][j]=C,ro=j;else Right[i][j]= i==1?ro-1:min(Right[i-1][j],ro-1),ans=max(ans,(Right[i][j]-Left[i][j]+1)*up[i][j]);}printf("%d\n", ans*3);}return 0;
}