记录编号 |
223010 |
评测结果 |
AAAAAAAAAAAAAAAA |
题目名称 |
[POI 1999] 位图 |
最终得分 |
100 |
用户昵称 |
FoolMike |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.042 s |
提交时间 |
2016-02-06 13:08:17 |
内存使用 |
0.67 MiB |
显示代码纯文本
type
point=record
x,y:longint;
end;
const
maxl=9999999;
var
map:array[0..183,0..183]of longint;
n,m,i,j,l,r,count:longint;
ch:char;
z:array[1..50000]of point;
procedure put(x,y:longint);
begin
inc(r);z[r].x:=x;z[r].y:=y;map[x,y]:=count;
end;
procedure bfs;
var
i:longint;
begin
for i:=l to r do
with z[i] do
begin
if map[x+1,y]>count then put(x+1,y);
if map[x-1,y]>count then put(x-1,y);
if map[x,y+1]>count then put(x,y+1);
if map[x,y-1]>count then put(x,y-1);
end;
end;
begin
assign(input,'bit.in');
reset(input);
assign(output,'bit.out');
rewrite(output);
readln(n,m);
for i:=1 to n do
begin
map[i,0]:=-1;map[i,m+1]:=-1;
end;
for j:=1 to m do
begin
map[0,j]:=-1;map[n+1,j]:=-1;
end;
for i:=1 to n do
begin
for j:=1 to m do
begin
read(ch);
if ch='0' then map[i,j]:=maxl else put(i,j);
end;
readln;
end;
l:=1;
repeat
inc(count);
i:=r+1;
bfs;
l:=i;
until l>r;
for i:=1 to n do
begin
for j:=1 to m do
write(map[i,j],' ');
writeln;
end;
close(input);
close(output);
end.