比赛 |
NOIP2008集训模拟1 |
评测结果 |
WEWEEEEEET |
题目名称 |
血色叛徒 |
最终得分 |
0 |
用户昵称 |
EnAsn |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-10 09:42:42 |
显示代码纯文本
program ex;
type
data=record
x,y:integer;
end;
ss=array[1..250000]of data;
sz=array[1..120]of integer;
var
a,b:ss;
f:sz;
f1,f2:text;
m,n,a1,b1:integer;
procedure init;
var
i:integer;
begin
assign(f1,'crusade.in');
assign(f2,'crusade.out');
reset(f1);
rewrite(f2);
readln(f1,n,m,a1,b1);
for i:=1 to a1 do readln(f1,a[i].x,a[i].y);
for i:=1 to b1 do readln(f1,b[i].x,b[i].y);
for i:=1 to m+n do f[i]:=maxint;
close(f1);
end;
procedure main;
var
i,j:integer;
t,t1,t2:integer;
begin
for i:=1 to a1 do
begin
t:=a[i].x+a[i].y;
t1:=t;
t2:=t;
while t1>0 do
begin
if t-t1<f[t1] then f[t1]:=t-t1;
dec(t1);
end;
while t2<=m+n do
begin
if t2-t<f[t2] then f[t2]:=t2-t;
inc(t2);
end;
end;
for i:=1 to b1 do
writeln(f2,f[b[i].x+b[i].y]);
{for i:=1 to m+n do
write(f2,f[i],' ');}
end;
begin
init;
main;
close(f2);
end.