Pagini recente » Cod sursa (job #648960) | Cod sursa (job #467489) | Cod sursa (job #2349429) | Cod sursa (job #2313018) | Cod sursa (job #1172409)
#include<fstream>
#include<vector>
#define mod 22817
#define pb push_back
#define FOR(a,b,c) for(int a=b;a<=c;++a)
using namespace std;
ifstream f("ograzi.in");
ofstream g("ograzi.out");
vector<int> X[mod],Y[mod];
int xj,yj,xs,ys,n,m,h,w,sol,mo,x,y,a,b;
void baga(int a,int b,int x,int y)
{
mo=(a+b)%mod;
X[mo].pb(x);
Y[mo].pb(y);
}
int cauta(int a,int b)
{
mo=(a+b)%mod;
int siz=X[mo].size();
siz--;
FOR(i,0,siz)
{
if(x>=X[mo][i]&&y>=Y[mo][i]&&x<=X[mo][i]+h&&y<=Y[mo][i]+w)
return 1;
}
return 0;
}
int main ()
{
f>>n>>m>>w>>h;
FOR(i,1,n)
{
f>>xj>>yj;
a=(xj+h-0.5)/h;
b=(yj+w-0.5)/w;
baga(a,b,xj,yj);
}
FOR(i,1,m)
{
f>>x>>y;
a=(x-0.5)/h;
b=(y-0.5)/w;
if(cauta(a,b)||cauta(a+1,b)||cauta(a,b+1)||cauta(a+1,b+1))
sol++;
}
g<<sol;
return 0;
}