Pagini recente » Cod sursa (job #3032841) | Cod sursa (job #191955) | Cod sursa (job #2059297) | Cod sursa (job #2118772) | Cod sursa (job #2668038)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ograzi.in");
ofstream fout("ograzi.out");
const int sigma = 997, mod = 100003;
int n, m, w, h;
vector <pair <int, int> > H[mod + 5];
bool Find(int x, int y, pair <int, int> p){
if (x < 0 || y < 0) return false;
int val = (x * sigma + y) % mod;
for (auto it : H[val]){
if (p.first <= it.first + w && p.first >= it.first && p.second <= it.second + h && p.second >= it.second){
return true;
}
}
return false;
}
int main(){
fin >> n >> m >> w >> h;
for (int i = 1; i <= n; ++i){
int x, y;
fin >> x >> y;
int val = (x / w * sigma + y / h) % mod;
H[val].push_back({x, y});
}
int contor = 0;
for (int i = 1; i <= m; ++i){
int x, y;
fin >> x >> y;
pair <int, int> aux = {x, y};
x /= w;
y /= h;
if (Find(x, y, aux) || Find(x - 1, y, aux) || Find(x, y - 1, aux) || Find(x - 1, y - 1, aux)){
++contor;
}
}
fout << contor << "\n";
fin.close();
fout.close();
return 0;
}