Pagini recente » Cod sursa (job #37576) | Statistici Catalin Filip (FilipCatalin) | Cod sursa (job #1735567) | Cod sursa (job #164529) | Cod sursa (job #2954484)
#include <fstream>
#include <vector>
using namespace std;
ifstream in ("ograzi.in");
ofstream out ("ograzi.out");
const int max_size = 5e4 + 1, mod = 666013, baza = 69;
struct str{
int xs, ys, xj, yj;
};
str a[max_size];
vector <pair <int, int>> hashuri[mod];
int main ()
{
int n, m, w, h;
in >> n >> m >> w >> h;
for (int i = 1; i <= n; i++)
{
in >> a[i].xs >> a[i].yj;
a[i].xj = a[i].xs + w;
a[i].ys = a[i].yj + h;
}
while (m--)
{
int x, y;
in >> x >> y;
hashuri[((x / w) * baza + y / h) % mod].push_back({x, y});
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
int dr = ((a[i].xs / w) * baza + a[i].ys / h) % mod;
for (auto f : hashuri[dr])
{
if (a[i].xs <= f.first && f.first <= a[i].xj && a[i].yj <= f.second && f.second <= a[i].ys)
{
ans++;
}
}
dr = ((a[i].xs / w) * baza + a[i].yj / h) % mod;
for (auto f : hashuri[dr])
{
if (a[i].xs <= f.first && f.first <= a[i].xj && a[i].yj <= f.second && f.second <= a[i].ys)
{
ans++;
}
}
dr = ((a[i].xj / w) * baza + a[i].ys / h) % mod;
for (auto f : hashuri[dr])
{
if (a[i].xs <= f.first && f.first <= a[i].xj && a[i].yj <= f.second && f.second <= a[i].ys)
{
ans++;
}
}
dr = ((a[i].xj / w) * baza + a[i].yj / h) % mod;
for (auto f : hashuri[dr])
{
if (a[i].xs <= f.first && f.first <= a[i].xj && a[i].yj <= f.second && f.second <= a[i].ys)
{
ans++;
}
}
}
out << ans;
in.close();
out.close();
}