为什么错,求指教

var
i,j,n,m,q,p,k,t,right,left,over,under,max:longint;
a,b:array[1..1000,1..1000] of longint;
function min(i,j:longint):longint;
begin
if i<j then exit(i);
if i=j then exit(i);
if i>j then exit(j);
end;
begin
max:=0;
readln(m,n);
for i:=1 to n do begin
for j:=1 to m do begin
read(a[i,j]);
end;
readln;
end;
for i:=1 to n do begin
for j:=1 to m do begin
if a[i,j]=0 then b[i,j]:=0;
if a[i,j]=1 then begin
for right:=i to n do begin
if a[right,j]=0 then begin
k:=right-1;
break;
end;
end;
for left:=i downto 1 do begin
if a[left,j]=0 then begin
t:=left+1;
break;
end;
end;
for over:=j to m do begin
if a[i,over]=0 then begin
q:=over-1;
break;
end;
end;
for under:=j downto 1 do begin
if a[i,under]=0 then begin
p:=under+1;
break;
end;
end;
b[i,j]:=min(k-t,q-p);
end;
end;
end;
for i:=1 to n do begin
for j:=1 to m do begin
if b[i,j]>max then max:=b[i,j];
end;
end;
writeln(max+1);
end.

0 条评论

目前还没有评论...

信息

ID
1057
难度
4
分类
动态规划 点击显示
标签
(无)
递交数
6668
已通过
3074
通过率
46%
被复制
8
上传者