Pagini recente » Cod sursa (job #377226) | Cod sursa (job #181536) | Cod sursa (job #1679555) | Cod sursa (job #1366067) | Cod sursa (job #1525210)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("ograzi.in");
ofstream fout("ograzi.out");
const int mod= 666013;
int n, m, w, h;
struct str {
int x, y;
};
vector <str> v[mod];
inline str mp( int x, int y ) {
str sol;
sol.x= x, sol.y= y;
return sol;
}
inline bool check( int k, int x, int y ) {
if ( k>=0 ) {
for ( vector <str>::iterator it= v[k].begin(); it!=v[k].end(); ++it ) {
if ( (*it).x<=x && (*it).x+w>=x && (*it).y<=y && (*it).y+h>=y ) {
return 1;
}
}
}
return 0;
}
int main( ) {
fin>>n>>m>>w>>h;
for ( int i= 1, x, y; i<=n; ++i ) {
fin>>x>>y;
v[((x/w)*1001+y/h)%mod].push_back(mp(x, y));
}
int sol= 0;
for ( int i= 1, x, y; i<=m; ++i ) {
fin>>x>>y;
int k1= ((x/w-1)*1001+y/h-1)%mod, k2= ((x/w-1)*1001+y/h)%mod, k3= ((x/w)*1001+y/h-1)%mod, k4= ((x/w)*1001+y/h)%mod;
if ( check(k1, x, y) || check(k2, x, y) || check(k3, x, y) || check(k4, x, y) ) {
++sol;
}
}
fout<<sol<<"\n";
return 0;
}