Pagini recente » Cod sursa (job #2022330) | Profil GogoantaAlexandraMihaela_321CC | Cod sursa (job #2736239) | Cod sursa (job #2006967) | Cod sursa (job #2025791)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n, m, w, h, sol;
unordered_map<int, pair <int, int> > have;
const int P = 1e9 + 7;
int cod(int x, int y) {
return x * P + y;
}
void addHash(int x, int y) {
have[cod(x / w, y / h)] = {x, y};
}
bool inside(int a, int b, int c, int d, int x, int y) {
return x >= a && x <= c && y >= b && y <= d;
}
bool inHash(ll codN) {
return have.find(codN) != end(have);
}
int main() {
ifstream cin("ograzi.in");
ofstream cout("ograzi.out");
cin >> n >> m >> w >> h;
for(int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
addHash(x, y);
}
for(int i = 1; i <= m; ++i) {
int x, y;
cin >> x >> y;
int cx = x / w, cy = y / h;
vector <pair<int, int> > check;
check.emplace_back(cx, cy), check.emplace_back(cx - 1, cy);
check.emplace_back(cx, cy - 1), check.emplace_back(cx - 1, cy - 1);
for(auto it : check) {
ll itcod = cod(it.first, it.second);
if(inHash (itcod)) {
int chkx = have[itcod].first, chky = have[itcod].second;
if(inside(chkx, chky, chkx + w, chky + h, x, y)) {
++sol;
break;
}
}
}
}
cout << sol;
return 0;
}