记录编号 |
5015 |
评测结果 |
AAATAATTTT |
题目名称 |
[POI 1999] 位图 |
最终得分 |
50 |
用户昵称 |
E.M.B.E.R |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
6.079 s |
提交时间 |
2008-10-24 15:49:08 |
内存使用 |
0.34 MiB |
显示代码纯文本
program EmberAsh;
const
d:array [1..4,1..2] of shortint=((1,0),(0,1),(-1,0),(0,-1));
var
map:array [1..200,1..200] of integer;{n*m的矩形位图}
qm:array [1..200*200,1..2] of integer; {i,j的两点之间距离}
x,y,closed,open,i,j,k,m,n:longint;
st:string;
BEGIN
assign(input,'bit.in');reset(input);
assign(output,'bit.out');rewrite(output);
readln(n,m);
open:=0;
for i:=1 to n do
begin{黑 白}
readln(st);
for j:=1 to m do
if st[j]='0' then map[i,j]:=255
else
begin{计算距离}
map[i,j]:=0;
inc(open);
qm[open,1]:=i;
qm[open,2]:=j;
end; {白像素}
end; {待扩展结点坐标个数}
closed:=0;
repeat
inc(closed);{第一个将要扩展的结点}
x:=qm[closed,1];
y:=qm[closed,2];
k:=map[x,y]; {增待扩展结点的颜色值255黑和0白}
for i:= 1 to 4 do{4个方向}
if (x+d[i,1] in [1..n])and(y+d[i,2] in [1..m])and(map[x+d[i,1],y+d[i,2]]>k+1) then
begin{如果增加的坐标在矩形位图范围内同时}
inc(open);{队尾新增待扩展结点}
qm[open,1]:=x+d[i,1];qm[open,2]:=y+d[i,2]; {新的待扩展结点坐标}
map[x+d[i,1],y+d[i,2]]:=k+1;
end;
until closed>=open;{结束}
for i := 1 to n do
begin
for j:=1 to m do
write(map[i,j],' ');
writeln;
end;
close(input);close(output);
END.