Pagini recente » Cod sursa (job #1163415) | Cod sursa (job #795999) | Cod sursa (job #241800) | Cod sursa (job #1971405) | Cod sursa (job #2639070)
#include <bits/stdc++.h>
#define MOD 100003
using namespace std;
ifstream f("ograzi.in");
ofstream g("ograzi.out");
int n,m,w,h,x,y,x2,y2,nr;
vector <pair <int,int> > v[100005];
void verif (int loc,pair <int,int> punct)
{
for (int j=0;j<v[loc].size();j++)
{
if (v[loc][j].first<=punct.first&&punct.first<=v[loc][j].first+w&&v[loc][j].second<=punct.second&&punct.second<=v[loc][j].second+h)
{
nr++;
}
}
}
int i;
int main()
{
f>> n >> m >> w >> h;
for (i=1;i<=n;i++)
{
f>>x>>y;
x2=(x+w-1)/w;
y2=(y+h-1)/h;
v[(x2*100+y2)%MOD].push_back({x,y});
}
for (i=1;i<=m;i++)
{
f>>x>>y;
x2=(x+w-1)/w;
y2=(y+h-1)/h;
verif((x2*100+y2)%MOD,{x,y});
verif(((x2-1)*100+y2)%MOD,{x,y});
verif(((x2-1)*100+y2-1)%MOD,{x,y});
verif((x2*100+y2-1)%MOD,{x,y});
}
g<<nr;
return 0;
}