Pagini recente » Cod sursa (job #2815523) | Cod sursa (job #494132) | Cod sursa (job #3198839) | Cod sursa (job #2725287) | Cod sursa (job #2639957)
#include <fstream>
#include <algorithm>
#include <queue>
#include <random>
#include <chrono>
#define x first
#define y second
using namespace std;
ifstream cin ("ograzi.in");
ofstream cout ("ograzi.out");
const int MOD = 666013;
const int P = 997;
int n, m, w, h, ans;
int x, y;
vector <pair <int, int>> table[MOD];
int cod(int x, int y) {
return (x * P + y) % MOD;
}
void check(int nr, int x, int y) {
for(auto &i : table[nr]) {
if(i.x <= x && x <= i.x + w && i.y <= y && y <= i.y + h) {
ans++;
return;
}
}
}
void solve() {
cin >> n >> m >> w >> h;
for(int i = 1; i <= n; i++) {
cin >> x >> y;
table[cod(x / w + 1, y / h + 1)].push_back({x, y});
}
ans = 0;
for(int i = 1; i <= m; i++) {
cin >> x >> y;
check(cod(x / w + 1, y / h + 1), x, y);
check(cod(x / w, y / h + 1), x, y);
check(cod(x / w + 1, y / h), x, y);
check(cod(x / w, y / h), x, y);
}
cout << ans << "\n";
}
int main() {
// tester();
solve();
return 0;
}