Pagini recente » Cod sursa (job #707299) | Cod sursa (job #2876209) | Istoria paginii info-oltenia-2019/individual/clasament/11-12 | Cod sursa (job #3293010) | Cod sursa (job #3132108)
#include <bits/stdc++.h>
#define MOD 500009
#define L 707
using namespace std;
ifstream fin("ograzi.in");
ofstream fout("ograzi.out");
int n, m, w, h, ans;
vector <pair <int, int>> v[MOD];
inline int shusta(int x, int y){
return (x * L + y) % MOD;
}
inline void add(int x, int y, int place){
for (auto it : v[place])
if (it.first <= x && x <= it.first + w && it.second <= y && y <= it.second + h){
ans++;
return;
}
}
int main(){
fin >> n >> m >> w >> h;
for (int i = 1; i <= n; i++){
int x, y;
fin >> x >> y;
v[shusta(x / w + 1, y / h + 1)].push_back({x, y});
}
for (int i = 1; i <= m; i++){
int x, y;
fin >> x >> y;
add(x, y, shusta(x / w + 1, y / h + 1));
add(x, y, shusta(x / w, y / h + 1));
add(x, y, shusta(x / w + 1, y / h));
add(x, y, shusta(x / w, y / h));
}
fout << ans << "\n";
return 0;
}