记录编号 |
8109 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[BYVoid S1] 血色叛徒 |
最终得分 |
100 |
用户昵称 |
zhai |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.394 s |
提交时间 |
2008-11-12 21:49:22 |
内存使用 |
0.59 MiB |
显示代码纯文本
program crusade;
var
aa:array[0..501,0..501]of integer;
a,b,c,d:longint;
procedure go;
var
i,j:longint;
Begin
for j:=1 to b do begin
for i:=1 to a do begin
if aa[i,j]+1<aa[i,j+1] then aa[i,j+1]:=aa[i,j]+1;
if aa[i,j]+1<aa[i+1,j] then aa[i+1,j]:=aa[i,j]+1;
end;
end;
for j:=b downto 1 do begin
for i:=a downto 1 do begin
if aa[i,j]+1<aa[i-1,j] then aa[i-1,j]:=aa[i,j]+1;
if aa[i,j]+1<aa[i,j-1] then aa[i,j-1]:=aa[i,j]+1;
end;
end;
End;
procedure ini;
var
i,j,x,y:longint;
Begin
assign(input,'crusade.in');
assign(output,'crusade.out');
reset(input); rewrite(output);
for i:=0 to 501 do begin
for j:=0 to 501 do aa[i,j]:=1001;
end;
readln(a,b,c,d);
for i:=1 to c do begin
readln(x,y);
aa[x,y]:=0;
end;
go;
for i:=1 to d do begin
readln(x,y);
writeln(aa[x,y]);
end;
close(input); close(output);
End;
Begin
ini;
End.