Pagini recente » Cod sursa (job #2692919) | Cod sursa (job #3224311) | Cod sursa (job #858036) | Cod sursa (job #709855) | Cod sursa (job #3290613)
#include <bits/stdc++.h>
#define mod 251063
using namespace std;
ifstream f("ograzi.in");
ofstream g("ograzi.out");
inline int key (int x, int y)
{
return (x*997+y)%mod;
}
struct elem
{
int x, y;
};
vector <elem> v[252000];
int dx[]={0, 0, -1, -1};
int dy[]={0, -1, 0, -1};
int main ()
{
int n, m, w, h, ans=0;
f >> n >> m >> w >> h;
for (int i=1; i<=n; i++)
{
int ox, oy;
f >> ox >> oy;
int x=ox/w+1, y=oy/h+1;
int val=key(x, y);
v[val].push_back ({ox,oy});
}
for (int i=1; i<=m; i++)
{
int ox, oy;
f >> ox >> oy;
int cx=ox/w+1, cy=oy/h+1;
bool ok=0;
for (int j=0; j<4; j++)
{
int x=cx+dx[j], y=cy+dy[j];
int val=key(x, y);
for (int k=0; k<v[val].size(); k++)
{
int xx=v[val][k].x, yy=v[val][k].y;
if (xx<=ox && xx+w>=ox && yy<=oy && yy+h>=oy)
{
ok=1;
break;
}
}
if (ok) break;
}
ans+=ok;
}
g << ans;
}