Pagini recente » Cod sursa (job #1780437) | Cod sursa (job #1609981) | Cod sursa (job #376029) | Cod sursa (job #683313) | Cod sursa (job #1593755)
#include <fstream>
#include <unordered_map>
#define x first
#define y second
#define ha 1009
#define MOD 2999963
using namespace std;
ifstream f("ograzi.in");
ofstream g("ograzi.out");
int i,n,t,h,w,x,y,rasp,x1,y1;
int m[3000000];
//int m[10];
pair<int,int> v[50002],a;
void check(int x,int y)
{
x1=x/w*ha;
y1=y/h;
a=v[m[(x1+y1+2*ha)%MOD]];
if (a.x <= x && x <= a.x+w && a.y <= y && y <= a.y+h)
{
++rasp;
return ;
}
a=v[m[(x1+y1+1*ha)%MOD]];
if (a.x <= x && x <= a.x+w && a.y <= y && y <= a.y+h)
{
++rasp;
return ;
}
a=v[m[(x1+y1-1+2*ha)%MOD]];
if (a.x <= x && x <= a.x+w && a.y <= y && y <= a.y+h)
{
++rasp;
return ;
}
a=v[m[(x1+y1-1+1*ha)%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[(x*ha+y+2*ha)%MOD]=i;
}
for(i=1;i<=t;++i)
{
f>>x>>y;
check(x,y);
}
g<<rasp;
return 0;
}