Pagini recente » Cod sursa (job #2222692) | Cod sursa (job #724149) | Cod sursa (job #3264428) | Cod sursa (job #2083342) | Cod sursa (job #1593709)
#include <fstream>
#include <unordered_map>
#define x first
#define y second
#define ha 10000000
#define MOD 3987654
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];
//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;
}