标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5567 Accepted Submission(s): 2401
1 #include<cstdio> 2 #include<cstring> 3 #include<cstring> 4 #include<algorithm> 5 #include<cstdlib> 6 using namespace std; 7 #define maxn 1000+5 8 int dp[maxn][maxn]; 9 int l[maxn],r[maxn]; 10 int main() 11 { 12 int n,m,ans; 13 char c[10]; 14 int t; 15 scanf("%d",&t); 16 while(t--) 17 { 18 scanf("%d%d",&n,&m); 19 memset(dp,0,sizeof(dp)); 20 for(int i=1;i<=n;i++) 21 { 22 for(int j=1;j<=m;j++) 23 { 24 scanf("%s",&c); 25 if(c[0]==‘F‘) 26 dp[i][j]=dp[i-1][j]+1; 27 else 28 dp[i][j]=0; 29 } 30 } 31 32 int ans=0; 33 for(int i=1;i<=n;i++) 34 { 35 l[1]=1; 36 r[m]=m; 37 dp[i][0]=-1; 38 dp[i][m+1]=-1; 39 for(int j=2;j<=m;j++) 40 { 41 l[j]=j; 42 while(dp[i][l[j]]<=dp[i][l[j]-1]) 43 l[j]=l[j]-1; 44 } 45 for(int j=m-1;j>=1;j--) 46 { 47 r[j]=j; 48 while(dp[i][r[j]]<=dp[i][r[j]+1]) 49 r[j]=r[j]+1; 50 } 51 for(int j=1;j<=m;j++) 52 ans=max(ans,(r[j]-l[j]+1)*dp[i][j]); 53 } 54 printf("%d\n",ans*3); 55 } 56 return 0; 57 }
标签:
原文地址:http://www.cnblogs.com/ZP-Better/p/4690943.html