显示代码纯文本
var
c,q:byte;
u,v,i,j,k,max,right,x:integer;
ans:longint;
di:array[-30000..30010] of integer;
p,f,h,g:array[1..701,0..700] of integer;
begin
assign(input,'land.in'); reset(input);
assign(output,'land.out'); rewrite(output);
readln(u,v,c);
for i:=1 to v do p[i,0]:=30001;
for i:=1 to u do p[v+1,i]:=30001;
c:=c+1;
for i:=1 to v do for j:=1 to u do read(h[i,j]);
for i:=0 to c-1 do di[i]:=0;
for i:=-1 downto -30000 do di[i]:=di[i+c]-1;
for i:=c to 30010 do di[i]:=di[i-c]+1;
for q:=0 to c-1 do begin
for i:=1 to v do for j:=1 to u do p[i,j]:=di[h[i,j]+q];
for i:=1 to u do begin
f[1,i]:=1;
for j:=2 to v do
if p[j,i]=p[j-1,i] then f[j,i]:=f[j-1,i]+1
else f[j,i]:=1;
end;
for i:=1 to v do begin
g[i,u]:=1;
for j:=u-1 downto 1 do
if p[i,j]=p[i,j+1] then begin g[i,j]:=g[i,j+1]+1; if g[i,j]>100 then g[i,j]:=100 end
else g[i,j]:=1;
end;
for i:=1 to u do
for j:=v downto 1 do begin
if (p[j,i]=p[j+1,i]) and (g[j,i]<=g[j+1,i]) then continue;
if (p[j,i]=p[j,i-1]) and (f[j,i]<=f[j,i-1]) then continue;
max:=f[j,i];
if f[j,i]>ans then ans:=f[j,i];
if i=u then continue;
right:=i+g[j,i]-1;
for k:=i+1 to right do begin
if f[j,k]<max then max:=f[j,k];
if max*(k-i+1)>ans then ans:=max*(k-i+1);
end;
end;
end;
writeln(ans);
close(input); close(output);
end.