比赛 |
NOIP2008集训模拟1 |
评测结果 |
AWATTWTWWT |
题目名称 |
血色叛徒 |
最终得分 |
20 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-10 08:26:43 |
显示代码纯文本
program cch(input,output);
const
xx:array[1..4] of integer=(-1,0,1,0);
yy:array[1..4] of integer=(0,1,0,-1);
var
i,j,n,m,s,c,x,y,q,k,x1,y1:integer;
a:array[1..500,1..500] of integer;
begin
assign(input,'crusade.in');
assign(output,'crusade.out');
reset(input);
rewrite(output);
readln(n,m,s,c);
for i:=1 to n do
for j:=1 to m do a[i,j]:=maxint;
for i:=1 to s do
begin
readln(x,y);
a[x,y]:=0;
end;
for i:=1 to n*m do
for j:=1 to n do
for q:=1 to m do
if a[j,q]<>maxint then
for k:=1 to 4 do
begin
x1:=j+xx[k]; y1:=q+yy[k];
if (x1>=1)and(x1<=n)and(y1>=1)and(y1<=m) then
if a[j,q]+1<a[x1,y1] then a[x1,y1]:=a[j,q]+1;
end;
for i:=1 to c do
begin
readln(x,y);
writeln(a[x,y]);
end;
close(input);
close(output);
end.