Pagini recente » Istoria paginii runda/f12_training_1/clasament | Statistici Luminita Nitescu (LuminitaNitescu) | Cod sursa (job #2005612) | Cod sursa (job #1869891) | Cod sursa (job #877645)
Cod sursa(job #877645)
#include<cstdio>
#include<tr1/unordered_map>
using std::tr1::unordered_multimap;
using std::pair;
using std::make_pair;
static int x[50005];
static int y[50005];
static int w,h;
struct hash_pair
{
int operator()(pair<int, int> p)const
{
return p.first^p.second;
}
};
#define MAP unordered_multimap<pair<int,int>, pair<int,int>, hash_pair>
#define IT MAP::iterator
#define inside(s,a,b) a<=s.first && a+w>=s.first && b<=s.second && b+h>=s.second
static MAP hash;
int main (void)
{
freopen ("ograzi.in","r",stdin);
#ifdef INFOARENA
freopen ("ograzi.out","w",stdout);
#endif
int n,m;
scanf ("%d%d%d%d",&n,&m,&w,&h);
for(int i=0;i<n;i++)
scanf ("%d %d",x+i,y+i);
for(int j=0;j<m;j++){
int x,y;
scanf ("%d%d",&x,&y);
hash.insert (make_pair (make_pair (x/w,y/h), make_pair (x,y)));
}
int ans=0;
for(int i=0;i<n;i++){
const int sa=x[i]/w;
const int sb=y[i]/h;
pair<IT,IT> p;
for(int a=sa;a<sa+2;a++)
for(int b=sb;b<sb+2;b++){
p=hash.equal_range (make_pair (a,b));
for(IT it=p.first;it!=p.second;it++)
if(inside (it->second,x[i],y[i]))
ans++;
}
}
printf ("%d",ans);
return 0;
}