Pagini recente » Cod sursa (job #376175) | Cod sursa (job #973445) | Cod sursa (job #670528) | Cod sursa (job #1068943) | Cod sursa (job #1040532)
#include<fstream>
#include<map>
#include<string>
using namespace std;
int n,oi,sol,h,w,x,y;
string s;
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;
}
void citesteNumere(int &x,int &y)
{
x=y=0;
getline(fin,s,' ');
for( int i=0;s[i]!=0;i++)
{
x=x*10+s[i]-'0';
}
getline(fin,s,'\n');
for(int i=0;s[i]!=0;i++)
{
y=y*10+s[i]-'0';
}
}
int main()
{
fin>>n>>oi>>w>>h;
fin.get();
pair<int,int> p;
for(int i=1;i<=n;i++)
{
citesteNumere(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++)
{
citesteNumere(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;
}