Pagini recente » Cod sursa (job #1205633) | Cod sursa (job #3275579) | Cod sursa (job #3140624) | Cod sursa (job #2932880) | Cod sursa (job #1764858)
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 50005;
const int kMod = 1000000007;
const int dx[] = {0, -1, 0, -1};
const int dy[] = {0, 0, -1, -1};
int n, m, w, h;
int xr[kMaxN];
int yr[kMaxN];
unordered_map <int, int> id;
inline int hashPair(const int x, const int y) {
return (x * 1000 + y) % kMod;
}
inline bool insideRectangle(const int i, const int x, const int y) {
return (xr[i] <= x && x <= xr[i] + h && yr[i] <= y && y <= yr[i] + w);
}
int main() {
freopen("ograzi.in", "r", stdin);
freopen("ograzi.out", "w", stdout);
scanf("%d %d %d %d", &n, &m, &w, &h);
for (int i = 1; i <= n; i++) {
scanf("%d %d", &xr[i], &yr[i]);
id[hashPair(xr[i] / w, yr[i] / h)] = i;
}
int cnt = 0;
while (m--) {
int x, y;
scanf("%d %d", &x, &y);
const int gx = x / w;
const int gy = y / h;
bool inside = false;
for (int i = 0; i < 4 && !inside; i++) {
unordered_map <int, int> :: iterator it = id.find(hashPair(gx + dx[i], gy + dy[i]));
if (it != id.end()) {
inside |= insideRectangle(it->second, x, y);
}
}
cnt += inside;
}
printf("%d\n", cnt);
return 0;
}