Pagini recente » Cod sursa (job #1043950) | Cod sursa (job #883525) | Cod sursa (job #2249554) | Cod sursa (job #3196827) | Cod sursa (job #253868)
Cod sursa(job #253868)
program grendizer;
var
f,g:TEXT;
n,m,x,y,i,x1,y1,x2,y2:longint;
r,st,dr,temp,contor:longint;
a:array[-2000..2000,-2000..2000]of integer;
begin
assign(f,'grendizer.in'); reset(f);
assign(g,'grendizer.out'); rewrite(g);
readln(f,n,m);
for i:=1 to n do
begin
readln(f,x,y);
a[x][y]:=1;
end;
for i:=1 to m do
begin
contor:=0;
readln(f,x1,y1,r);
if(r>1200)then
begin
writeln(g,0);
continue;
end;
st:=x1-r;
dr:=x1+r;
if(st>dr)then
begin
temp:=st;
st:=dr;
dr:=temp;
end;
if(st<-300)then st:=-300;
if(dr>300)then dr:=300;
for x2:=st to dr do
begin
temp:=r-abs(x1-x2);
if(temp>=0)then
begin
{cazul unu y1-y2 = temp }
y2:=y1-temp;
if(a[x2][y2]=1)then contor:=contor+1;
{cazul doi -y1+y2 = temp }
y2:=temp+y1;
if(a[x2][y2]=1)then
if(temp+y1)<>(y1-temp)then
contor:=contor+1;
end;
end;
writeln(g,contor);
end;
close(f); close(g);
end.