Pagini recente » Cod sursa (job #683400) | Cod sursa (job #781237) | Cod sursa (job #1077831) | Cod sursa (job #432382) | Cod sursa (job #1593712)
#include <fstream>
#include <unordered_map>
#define x first
#define y second
#define ha 10000000
#define MOD 1987654
using namespace std;
ifstream f("ograzi.in");
ofstream g("ograzi.out");
int i,n,t,h,w,x,y,rasp,x1,y1;
int m[4000000];
#define m (m+2000000)
//int m[10];
pair<int,int> v[50001],a;
///)%MOD
void check(int x,int y)
{
a=v[m[(1ll*x/w*ha+y/h)%MOD]];
if (a.x <= x && x <= a.x+w && a.y <= y && y <= a.y+h)
{
++rasp;
return ;
}
a=v[m[(1ll*(-1+x/w)*ha+y/h)%MOD]];
if (a.x <= x && x <= a.x+w && a.y <= y && y <= a.y+h)
{
++rasp;
return ;
}
a=v[m[(1ll*x/w*ha+y/h-1)%MOD]];
if (a.x <= x && x <= a.x+w && a.y <= y && y <= a.y+h)
{
++rasp;
return ;
}
a=v[m[(1ll*(-1+x/w)*ha+y/h-1)%MOD]];
if (a.x <= x && x <= a.x+w && a.y <= y && y <= a.y+h)
{
++rasp;
return ;
}
}
int main()
{
f>>n>>t>>w>>h;
for (i=1;i<=n;++i)
{
f>>x>>y;
v[i]={x,y};
x/=w;
y/=h;
m[(1ll*x*ha+y)%MOD]=i;
}
for(i=1;i<=t;++i)
{
f>>x>>y;
check(x,y);
}
g<<rasp;
return 0;
}