Pagini recente » Cod sursa (job #2398665) | Cod sursa (job #1446199) | Cod sursa (job #2402813) | Cod sursa (job #46728) | Cod sursa (job #350500)
Cod sursa(job #350500)
#include <iostream>
#include <vector>
using namespace std;
#define pb push_back
#define Sz size()
#define mp make_pair
typedef pair<int,int>pii;
int n,m,h,w,a,b,ans,x1,y1,x2,y2;
vector<pii>v;
void open(){
freopen("ograzi.in","r",stdin);
freopen("ograzi.out","w",stdout);
}
int main(){
open();
scanf("%d%d%d%d",&n,&m,&h,&w);
for (int i=0;i<n;i++){
scanf("%d %d",&a,&b);
v.pb(mp(a,b));
}
sort(v.begin(),v.end());
ans=0;
for (int i=0;i<m;i++){
scanf("%d %d",&a,&b);
int lo=lower_bound(v.begin(),v.end(),mp(a,b))-v.begin();
if (lo==0){
x1=v[lo].first;
y1=v[lo].second;
x2=x1+h;
y2=y1+w;
if (a>=x1 && b>=y1 && a<=x2 && b<=y2) ans++;
}
else {
x1=v[lo].first;
y1=v[lo].second;
x2=x1+h;
y2=y1+w;
if (a>=x1 && b>=y1 && a<=x2 && b<=y2) ans++;
else {
lo--;
x1=v[lo].first;
y1=v[lo].second;
x2=x1+h;
y2=y1+w;
if (a>=x1 && b>=y1 && a<=x2 && b<=y2) ans++;
}
}
}
printf("%d\n",ans);
//system("pause");
return 0;
}