Pagini recente » Cod sursa (job #888537) | Cod sursa (job #70803) | Cod sursa (job #49428) | Cod sursa (job #268027) | Cod sursa (job #1061075)
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD=66617;
const int MAX_N=50100;
int h,w;
inline int hash(int x,int y) {
x/=w;
y/=h;
return ((x%MOD)*327 + (y%MOD)*581)%MOD;
}
vector<int> H[MOD + 100];
pair<int,int> v[MAX_N];
bool intersect(int x,int y,int poz) {
return (x>=v[poz].first && x<=v[poz].first+w) && (y>=v[poz].second && y<=v[poz].second +h);
}
int main() {
freopen("ograzi.in","r",stdin);
freopen("ograzi.out","w",stdout);
int n,m;
scanf("%d%d%d%d",&n,&m,&w,&h);
for(int i=1;i<=n;i++) {
scanf("%d%d",&v[i].first,&v[i].second);
H[ hash( v[i].first , v[i].second) ].push_back(i);
H[ hash( v[i].first + w , v[i].second) ].push_back(i);
H[ hash( v[i].first , v[i].second + h) ].push_back(i);
H[ hash( v[i].first + w , v[i].second + h) ].push_back(i);
}
int ans=0;
for(int i=1;i<=m;i++) {
int x,y;
scanf("%d%d",&x,&y);
for(vector<int>::iterator it=H[hash(x,y)].begin(); it!=H[hash(x,y)].end(); it++) {
if(intersect(x,y,*it)) {
ans++;
break;
}
}
}
printf("%d",ans);
return 0;
}