Pagini recente » Cod sursa (job #505255) | Cod sursa (job #1160103) | Cod sursa (job #1678335) | Cod sursa (job #843452) | Cod sursa (job #842596)
Cod sursa(job #842596)
#include <cstdio>
#include <cassert>
#include <map>
#define x first
#define y second
using namespace std;
typedef pair<int, int> Point;
const int DX[] = {0, -1, 0, -1}, DY[] = {0, 0, -1, -1};
const int MaxN = 50005;
map<Point, Point> Hash;
int W, H;
inline bool Inside(const Point R, const Point P) {
return (R.x <= P.x && P.x <= R.x + W && R.y <= P.y && P.y <= R.y + H);
}
inline void Insert(const Point P) {
Hash[Point(P.x / W, P.y / H)] = P;
}
inline bool CheckPoint(const Point P) {
for (int d = 0; d < 4; ++d) {
Point GridP = Point(P.x / W + DX[d], P.y / H + DY[d]);
if (Hash.find(GridP) != Hash.end() && Inside(Hash[GridP], P))
return true;
}
return false;
}
int main() {
assert(freopen("ograzi.in", "r", stdin));
assert(freopen("ograzi.out", "w", stdout));
int N, M; assert(scanf("%d %d %d %d", &N, &M, &W, &H)== 4);
for (; N > 0; --N) {
Point P; assert(scanf("%d %d", &P.x, &P.y) == 2);
Insert(P);
}
int Solution = 0;
for (; M > 0; --M) {
Point P; assert(scanf("%d %d", &P.x, &P.y) == 2);
Solution += CheckPoint(P);
}
printf("%d\n", Solution);
return 0;
}