比赛 |
2008haoi模拟训练3 |
评测结果 |
AAAATTTTTT |
题目名称 |
位图 |
最终得分 |
40 |
用户昵称 |
SMXX |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-04-24 09:45:22 |
显示代码纯文本
program bit;
type
ee=record
a,b:1..182;
end;
var
f1,f2:text;
n,m,i,j,l,g,h,k,o:integer;
a:array[1..182]of string;
b:array[1..182,1..182]of 0..365;
c:array[1..33125]of ee;
procedure print;
var i,j:integer;
begin
for i:= 1to n do begin
for j:=1 to m-1 do begin
if b[i,j]=365 then b[i,j]:=0;
write(f2,b[i,j],' ');
end;
if b[i,m]=365 then b[i,m]:=0;
writeln(f2,b[i,m]);
end;
end;
begin
assign(f1,'bit.in');
assign(f2,'bit.out');
reset(f1);
rewrite(f2);
readln(f1,n,m);
k:=0;
for i:= 1to n do begin
readln(f1,a[i]);
for j:= 1to m do
if a[i][j]='1' then begin inc(k);c[k].a:=i;c[k].b:=j;end;
end;
if k=n*m then print
else begin
for i:= 1to n do
for j:= 1to m do b[i,j]:=365;
for l:=1 to k do
for g:= 1to n do
for h:= 1to m do
if a[g][h]='0' then begin
o:=abs(g-c[l].a)+abs(h-c[l].b);
if o<b[g,h] then b[g,h]:=o;
end;
print;
end;
close(f1);
close(f2);
end.