Pagini recente » Cod sursa (job #2172614) | Cod sursa (job #1843612) | Cod sursa (job #2056706) | Cod sursa (job #377798) | Cod sursa (job #2709585)
#include <bits/stdc++.h>
#define mod 100003
using namespace std;
ifstream f ("ograzi.in");
ofstream g ("ograzi.out");
vector <pair<int,int> > v[100005];
int n,m,w,h;
int rasp;
void cauta (int loc, int x, int y)
{
if(loc<0)
return;
for(int i=0; i<v[loc].size(); ++i)
{
if(v[loc][i].first<=x && x<=v[loc][i].first+w && v[loc][i].second<=y && y<=v[loc][i].second+h )
{
++rasp;
}
}
}
int main()
{
f>>n>>m>>w>>h;
for(int i=1; i<=n; ++i)
{
int x, y;
f>>x>>y;
x=(x+h-1)/w;
y=(y+w-1)/h;
v[(x*100+y)%mod].push_back({x,y});
}
for(int i=1; i<=m; ++i)
{
int x,y;
f>>x>>y;
x=(x-1+w)/w;
y=(y-1+h)/h;
cauta((x*100+y)%mod, x, y);
cauta((x*100+y-1)%mod, x, y);
cauta(((x-1)*100+y)%mod, x,y);
cauta(((x-1)*100+y-1)%mod, x, y );
}
g<<rasp;
return 0;
}