Pagini recente » Cod sursa (job #2634442) | Borderou de evaluare (job #1569752) | Cod sursa (job #987267) | Cod sursa (job #1975938) | Cod sursa (job #2932082)
#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){
int poz = (a * c1 + b * c2) % mod;
for(auto e : L[poz])
return (x >= e.x && x <= e.x + h && y >= e.y && y <= e.y + w);
}
void Read(){
std::ios::sync_with_stdio(false);
fin.tie (nullptr);
fin >> n >> m >> w >> h;
Elem e;
for(int i = 1; i <= n; i++){
fin >> e.x >> e.y;
int a = e.x / h;
int b = e.y / w;
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;
int a = x / h;
int b = y / w;
sol += Find(a, b, x, y);
sol += Find(a - 1, b, x, y);
sol += Find(a, b - 1, x, y);
sol += Find(a - 1, b - 1, x, y);
}
fout << sol << "\n";
fout.close();
}
int main()
{
Read();
return 0;
}