Pagini recente » Clasament 253913 | Cod sursa (job #283736) | Cod sursa (job #1262785) | Cod sursa (job #2416734) | Cod sursa (job #2709589)
#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()
{
ios_base::sync_with_stdio(false);
f.tie(NULL);
f>>n>>m>>w>>h;
for(int i=1; i<=n; ++i)
{
int x, y;
f>>x>>y;
int x1=(x+h-1)/w;
int y1=(y+w-1)/h;
v[(x1*100+y1)%mod].push_back({x,y});
}
for(int i=1; i<=m; ++i)
{
int x,y;
f>>x>>y;
int x1=(x+h-1)/w;
int y1=(y+w-1)/h;
cauta((x1*100+y1)%mod, x, y);
cauta((x1*100+y1-1)%mod, x, y);
cauta(((x1-1)*100+y1)%mod, x,y);
cauta(((x1-1)*100+y1-1)%mod, x, y );
}
g<<rasp;
return 0;
}