题解:这个,是我这辈子第一次成功的写最大子矩阵问题呵呵呵(phile:这这这。。。 HansBug:我是蒟蒻求不鄙视TT)。仔细说下子——首先通过二重循环递推出各个F点的左边,右边,下边各有多少个F(均算自己在内),然后开工——枚举每一个点,当为1的时候凉拌,为0的时候开始向下“挂线”(这正是网上所说的悬线法)——假如这个点正下方为0,则当啥都没做(本程序里面还是执行了下内循环,虽然次数为0。。= =);假如刚好是个1,那就顺藤摸瓜一直往下,每往下一格便记录下这根线当前左侧最窄值为多少,右侧最窄值为多少,然后当已经挂到长度为K时,则当前最新面积为K*(左侧最窄值+右侧最窄值-1)(PS:记得减1),然后每次max一下,结果就出来啦(特特特特特特特别提醒:记得乘3!!!!)
1 var
2 i,j,k,l,m,n,ans,a1,a2:longint;
3 a,lef,rig,dow:array[0..1100,0..1100] of longint;
4 c1:char;
5 function min(x,y:longint):longint;inline;
6 begin
7 if x<y then min:=x else min:=y;
8 end;
9 function max(x,y:longint):longint;inline;
10 begin
11 if x>y then max:=x else max:=y;
12 end;
13 begin
14 readln(n,m);
15 for i:=1 to n do
16 begin
17 a[i,0]:=0;
18 while not(eoln) do
19 begin
20 read(c1);c1:=upcase(c1);
21 if (c1<>‘F‘) and (c1<>‘R‘) then continue;
22 inc(a[i,0]);
23 if c1=‘F‘ then a[i,a[i,0]]:=1 else a[i,a[i,0]]:=0;
24 end;
25 readln;
26 a[i,0]:=0;
27 end;
28 for i:=1 to n do
29 for j:=1 to m do
30 if a[i,j]=1 then lef[i,j]:=lef[i,j-1]+1 else lef[i,j]:=0;
31 for i:=n downto 1 do
32 for j:=m downto 1 do
33 begin
34 if a[i,j]=1 then rig[i,j]:=rig[i,j+1]+1 else rig[i,j]:=0;
35 if a[i,j]=1 then dow[i,j]:=dow[i+1,j]+1 else dow[i,j]:=0;
36 end;
37 ans:=0;
38 for i:=0 to n do
39 for j:=1 to m do
40 if a[i,j]=0 then
41 begin
42 a1:=-1;
43 a2:=-1;
44 for k:=1 to dow[i+1,j] do
45 begin
46 if a1=-1 then a1:=lef[i+k,j] else a1:=min(a1,lef[i+k,j]);
47 if a2=-1 then a2:=rig[i+k,j] else a2:=min(a2,rig[i+k,j]);
48 ans:=max(ans,(a1+a2-1)*k);
49 end;
50 if a1=-1 then continue;
51 end;
52 writeln(ans*3);
53 end.