Pagini recente » Cod sursa (job #1580263) | Cod sursa (job #2689366) | Cod sursa (job #1285027) | Cod sursa (job #3183940) | Cod sursa (job #1040502)
#include<fstream>
#include<map>
using namespace std;
int n,oi,sol,h,w,x,y;
map<pair<int,int> , pair<int,int> > m;
ifstream fin("ograzi.in");
ofstream fout("ograzi.out");
int sePoate(pair<int,int> p,int x,int y)
{
pair<int,int>res;
if(m.find(p)==m.end())
{
return 0;
}
res=m[p];
if(res.first<=x && x<=res.first+w && res.second<=y && y<=res.second+h)
{
sol++;
return 1;
}
return 0;
}
int main()
{
fin>>n>>oi>>w>>h;
pair<int,int> p;
for(int i=1;i<=n;i++)
{
fin>>x>>y;
p.first=(int)((x+w-0.5)/w);
p.second=(int)((y+h-0.5)/h);
m[p]=make_pair(x,y);
}
for(int i=1;i<=oi;i++)
{
fin>>x>>y;
p.first=(int)(x-0.5)/w;
p.second=(int)(y-0.5)/h;
if(sePoate(p,x,y))
continue;
p.first++;
if(sePoate(p,x,y))
continue;
p.first--;
p.second++;
if(sePoate(p,x,y))
continue;
p.first++;
if(sePoate(p,x,y))
continue;
}
fout<<sol;
return 0;
}