Pagini recente » Cod sursa (job #2827120) | Cod sursa (job #469427) | Cod sursa (job #2541175) | Cod sursa (job #408116) | Cod sursa (job #25460)
Cod sursa(job #25460)
type punct=record
x,y:integer;
end;
var a:array [1..3000,1..3000] of word;
o:array [1..50000] of punct;
n,m,w,h,all:longint;
procedure update(x,y:integer);
var i,j:integer;
begin
i:=x;
while i<=3000 do
begin
j:=y;
while j<=3000 do
begin
inc(a[i,j]);
j:=j+(j xor (j-1))and j;
end;
i:=i+(i xor (i-1))and i;
end;
end;
procedure citire;
var i,x,y:longint;
begin
assign(input,'ograzi.in');
reset(input);
readln(n,m,w,h);
for i:=1 to n do
readln(o[i].x,o[i].y);
for i:=1 to m do
begin
readln(x,y);
update(x+1,y+1);
end;
close(input);
end;
function suma(x,y:integer):word;
var s,i,j:word;
begin
s:=0;
i:=x;
while i>0 do
begin
j:=y;
while j>0 do
begin
s:=s+a[i,j];
j:=j-(j xor (j-1))and j;
end;
i:=i-(i xor (i-1))and i;
end;
suma:=s;
end;
procedure prel;
var i:longint;
begin
for i:=1 to n do
all:=all+suma(o[i].x+w+1,o[i].y+h+1)+suma(o[i].x,o[i].y)-suma(o[i].x+w+1,o[i].y)-suma(o[i].x,o[i].y+h+1);
end;
begin
citire;
prel;
assign(output,'ograzi.out');
rewrite(output);
writeln(all);
close(output);
end.