比赛 2008haoi模拟训练3 评测结果 WWWWTTTTTT
题目名称 位图 最终得分 0
用户昵称 zxc111 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-04-24 10:38:29
显示代码纯文本
program ooo;

var
t:text;
a,b,j,k,i,m,n:longint;
u,o:array[1..182,1..182] of integer;
s:string;
begin
assign(t,'bit.in');
reset(t);
readln(t,a,b);
for j:=1 to a do
begin
 readln(t,s);
for k:=1 to b do
u[j,k]:=ord(s[k])-ord('0');
end;
 close(t);
fillchar(o,sizeof(o),10000);
for j:=1 to a do
 for k:=1 to b do
  if u[j,k]=1 then
  begin
  for m:=j downto 1 do
 begin
  for n:=k downto 1 do
 if (u[m,n]<>1) then
 if (o[m,n]>abs(j-m)+abs(k-n)) then o[m,n]:=abs(j-m)+abs(k-n) else
 else o[m,n]:=0;
for n:=k+1 to b do
 if (u[m,n]<>1) then
 if (o[m,n]>abs(j-m)+abs(k-n)) then o[m,n]:=abs(j-m)+abs(k-n) else
 else o[m,n]:=0;
end;
  for m:=j to a do
begin
  for n:=k to b do
 if (u[m,n]<>1) then
 if(o[m,n]>abs(j-m)+abs(k-n)) then o[m,n]:=abs(j-m)+abs(k-n) else
  else o[m,n]:=0;
for n:=k downto 1 do
 if (u[m,n]<>1) then
 if (o[m,n]>abs(j-m)+abs(k-n)) then o[m,n]:=abs(j-m)+abs(k-n) else
 else o[m,n]:=0;
  end;
  end;
  assign(t,'bit.out');
  rewrite(t);

for j:=1 to a do
 begin
 for k:=1 to b-1 do
 write(t,o[j,k],' ');
 write(t,o[j,b]);
 writeln(t);
 end;
end.