Pagini recente » Cod sursa (job #362378) | Cod sursa (job #1735955)
#include <iostream>
#include <fstream>
#include <map>
#define a first
#define b second
#define mp make_pair
using namespace std;
map< pair<int, int>, pair<int, int> > mt;
int n, m, w, h;
inline bool ino(int x, int y)
{
for(int i = 0; i <= 1; ++i)
for(int j = 0; j <= 1; ++j)
{
if(mt.find(mp(x/w - i, y/h - j)) != mt.end())
{
pair<int, int> coord = mt[mp(x/w - i, y/h - j)];
if(coord.a+w >= x && coord.b+h >= y)
return 1;
}
}
return 0;
}
int main()
{
ifstream f("ograzi.in");
ofstream g("ograzi.out");
f >> n >> m >> w >> h;
for(int i = 1; i <= n; ++i)
{
int x, y;
f >> x >> y;
mt[mp(x/w, y/h)] = mp(x, y);
}
int nr = 0;
for(int i = 1; i <= m; ++i)
{
int x, y;
f >> x >> y;
nr += ino(x, y);
}
g << nr;
}