经典题目不多说

 1 var f:array[0..1010,0..1010] of longint;
 2     l,r:array[0..1010] of longint;
 3     i,j,n,m,ans:longint;
 4     x:char;
 5 
 6 function max(a,b:longint):longint;
 7   begin
 8     if a>b then exit(a) else exit(b);
 9   end;
10 
11 begin
12   readln(n,m);
13   for i:=1 to n do
14   begin
15     for j:=1 to m do
16     begin
17       read(x);
18       if x=' ' then read(x);
19       if x='F' then
20         f[i,j]:=f[i-1,j]+1
21       else f[i,j]:=0;
22     end;
23     readln;
24   end;
25 
26   for i:=1 to n do
27   begin
28     l[1]:=1;
29     for j:=1 to m do
30     begin
31       l[j]:=j;
32       while (l[j]-1>0) and (f[i,j]<=f[i,l[j]-1]) do l[j]:=l[l[j]-1];
33     end;
34     r[m]:=m;
35     for j:=m-1 downto 1 do
36     begin
37       r[j]:=j;
38       while (r[j]+1<=m) and (f[i,j]<=f[i,r[j]+1]) do r[j]:=r[r[j]+1];
39     end;
40     for j:=1 to m do
41       ans:=max(ans,f[i,j]*(r[j]-l[j]+1));
42   end;
43   writeln(3*ans);
44 end.
View Code

 

posted on 2014-06-29 22:55  acphile  阅读(127)  评论(0编辑  收藏  举报