Pagini recente » Cod sursa (job #1099151) | Cod sursa (job #2807572) | Cod sursa (job #2279172) | Cod sursa (job #657525) | Cod sursa (job #2932099)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ograzi.in");
ofstream fout("ograzi.out");
int n, m, w, h;
const int c1 = 43, c2 = 19, mod = 14411;
struct Elem{
int x, y;
};
vector <Elem> L[15005];
int Find(int a, int b, int x, int y){
if(a < 0 || b < 0) return 0;
int poz = (a * c1 + b * c2) % mod;
for(auto e : L[poz])
return (x >= e.x && x <= e.x + w && y >= e.y && y <= e.y + h);
}
void Read(){
std::ios::sync_with_stdio(false);
fin.tie (nullptr);
// InputReader fin("ograzi.in");
fin >> n >> m >> w >> h;
Elem e;
for(int i = 1; i <= n; i++){
fin >> e.x >> e.y;
e.x++;
e.y++;
int a = e.x / w;
int b = e.y / h;
int poz = (a * c1 + b * c2) % mod;
L[poz].push_back(e);
///dreptunghi
}
int x, y;
int sol = 0;
for(int i = 1; i <= m; i++){
fin >> x >> y;
x++;
y++;
int a = x / w;
int b = y / h;
sol += (Find(a, b, x, y) | Find(a - 1, b, x, y) | Find(a, b - 1, x, y) | Find(a - 1, b - 1, x, y));
}
fout << sol << "\n";
fout.close();
}
int main()
{
Read();
return 0;
}