记录编号 |
7557 |
评测结果 |
AWAAAWWWWW |
题目名称 |
[BYVoid S1] 血色叛徒 |
最终得分 |
40 |
用户昵称 |
打不死的羊 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.354 s |
提交时间 |
2008-11-10 17:16:49 |
内存使用 |
2.26 MiB |
显示代码纯文本
program crusade;
type
fxz1=array[1..500,1..500] of longint;
fxz2=record x,y:integer;end;
fxz3=array[1..250000] of fxz2;
fxz4=array[1..500,1..500] of boolean;
var
f1,f2:text;
i,j,x,y,n,m,a,b,t,w,l,time:longint;
map:fxz1;
gr:fxz3;
flag:fxz4;
procedure sc(i:integer);
begin
if (gr[i].x+1<=n)and(flag[gr[i].x+1,gr[i].y]) then
begin map[gr[i].x+1,gr[i].y]:=time;
flag[gr[i].x+1,gr[i].y]:=false;
inc(l);
gr[l].x:=gr[i].x+1;
gr[l].y:=gr[i].y;
end;
if (gr[i].x-1>=1)and(flag[gr[i].x-1,gr[i].y]) then
begin map[gr[i].x-1,gr[i].y]:=time;
flag[gr[i].x-1,gr[i].y]:=false;
inc(l);
gr[l].x:=gr[i].x-1;
gr[l].y:=gr[i].y;
end;
if (gr[i].y+1<=m)and(flag[gr[i].x,gr[i].y+1]) then
begin map[gr[i].x,gr[i].y+1]:=time;
flag[gr[i].x,gr[i].y+1]:=false;
inc(l);
gr[l].x:=gr[i].x;
gr[l].y:=gr[i].y+1;
end;
if (gr[i].y-1>=1)and(flag[gr[i].x,gr[i].y-1]) then
begin map[gr[i].x,gr[i].y-1]:=time;
flag[gr[i].x,gr[i].y-1]:=false;
inc(l);
gr[l].x:=gr[i].x;
gr[l].y:=gr[i].y-1;
end;
end;
begin
assign(f1,'crusade.in');
assign(f2,'crusade.out');
reset(f1);rewrite(f2);
readln(f1,n,m,a,b);
for i:=1 to n do
for j:=1 to m do
begin
map[i,j]:=0;
flag[i,j]:=true;
end;
for i:=1 to a do
begin
readln(f1,gr[i].x,gr[i].y);
map[gr[i].x,gr[i].y]:=0;
flag[gr[i].x,gr[i].y]:=false;
end;
t:=1;w:=a;l:=w;
time:=1;
while t<=w do
begin
for i:=t to w do sc(i);
t:=w+1;
w:=l;
inc(time);
end;
for i:=1 to b do
begin
readln(f1,x,y);
writeln(f2,map[x,y]);
end;
close(f1);close(f2);
end.