Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3959 Accepted Submission(s): 1651
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 |
#include<stdio.h> #include<string.h> #define M 1005 int a[M][M],l[M],r[M]; int main() { int
t,i,j, max,ans,n,m; char
str[10]; scanf ( "%d" ,&t); while (t--&& scanf ( "%d %d" ,&n,&m)) { memset (a[0],0, sizeof (a[0])); for (i=1;i<=n;i++) for (j=1;j<=m;j++) { scanf ( "%s" ,str); if (str[0]== ‘F‘ ) a[i][j]=a[i-1][j]+1; else
a[i][j]=0; } max=-1; for (i=1;i<=n;i++) { for (j=1;j<=m;j++) l[j]=r[j]=j; a[i][0]=a[i][m+1]=-1; //边界,不加边界就会超时。 for (j=2;j<=m;j++) { while (a[i][j]<=a[i][l[j]-1]) l[j]=l[l[j]-1]; } for (j=m-1;j>=1;j--) { while (a[i][j]<=a[i][r[j]+1]) r[j]=r[r[j]+1]; } for (j=1;j<=m;j++) { ans=a[i][j]*(r[j]-l[j]+1); if (max<ans) max=ans; } } printf ( "%d\n" ,max*3); } return
0; } |
原文:http://www.cnblogs.com/cancangood/p/3567143.html