Pagini recente » Cod sursa (job #1455548) | Cod sursa (job #1504490) | Cod sursa (job #660804) | Cod sursa (job #1899797) | Cod sursa (job #1172896)
#include <fstream>
#include <vector>
#include <cstring>
#define vint vector<point>::iterator
#define mod 666013
using namespace std;
ifstream fin ("ograzi.in");
ofstream fout ("ograzi.out");
struct point
{
int x,y;
};
int n,m,w,h,hh,x,xx,y,yy,p,len,nr;
vector<point> H[mod];
char s[3000000];
int get_int ()
{
int x = 0;
for (; p < len; ++p)
{
if ('0' <= s[p] && s[p] <= '9')
{
x = x*10 + s[p] - '0';
}
else
{
++p;
break;
}
}
return x;
}
bool test (int x, int y, int hh)
{
for (vint it = H[hh].begin (); it != H[hh].end(); ++it)
{
if (it->x <= x && x <= it->x + w && it->y <= y && y <= it->y + h)
return 1;
}
return 0;
}
int main()
{
freopen ("ograzi.in","r",stdin);
fread (s,1,3000000,stdin);
len = strlen(s);
p = 0;
n = get_int ();
m = get_int ();
w = get_int ();
h = get_int ();
for (int i=1; i<=n; ++i)
{
x = get_int ();
y = get_int ();
if (x % w == 0)
xx = x;
else xx = (x/w + 1)*w;
if (y % h == 0)
yy = y;
else yy = (y/h + 1)*h;
hh = 1LL*xx*yy%mod;
point P; P.x = x; P.y = y;
H[hh].push_back (P);
}
for (int i=1; i<=m; ++i)
{
x = get_int ();
y = get_int ();
if (x % w == 0)
xx = x - w;
else xx = x/w*w;
if (y % h == 0)
yy = y - h;
else yy = y/h*h;
if (test (x,y,1LL*xx*yy%mod))
{
++nr;
continue;
}
xx += w;
if (test (x,y,1LL*xx*yy%mod))
{
++nr;
continue;
}
yy += h;
if (test(x,y,1LL*xx*yy%mod))
{
++nr;
continue;
}
xx -= w;
if (test(x,y,1LL*xx*yy%mod))
{
++nr;
}
}
fout<<nr;
}