Pagini recente » Cod sursa (job #692735) | Cod sursa (job #1374885) | Cod sursa (job #1134857) | Cod sursa (job #1160568) | Cod sursa (job #1181242)
Program ograzi;
const prim=1000001;
type list=^cell;
cell=record
infodown:longint;
infoup:longint;
pred:list;
end;
var n,m,w,h,i,j,a,b,k : longint;
lhash : array[0..1000001] of list;
r : list;
b1,b2 : array [0..1 shl 10] of char;
procedure add(down,up : longint;var v : list);
var r :list;
begin
new(r);
r^.infodown:=down;
r^.infoup:=up;
r^.pred:=v;
v:=r;
end;
begin
assign(input,'ograzi.in'); settextbuf(input,b1); reset(input);
assign(output,'ograzi.out'); settextbuf(output,b2); rewrite(output);
readln(n,m,w,h);
for i:=1 to n do begin
readln(a,b);
for j:=a to a+w do
add(b,b+h,lhash[j mod prim]);
end;
k:=0;
for i:=1 to m do begin
readln(a,b);
r:=lhash[a mod prim];
while r<>nil do begin
if (r^.infodown<=b) and (r^.infoup>=b) then k:=k+1;
r:=r^.pred;
end;
end;
writeln(k);
close(input);
close(output) ;
end.