Pagini recente » Cod sursa (job #774101) | Cod sursa (job #2870430) | Cod sursa (job #1240885) | Cod sursa (job #998626) | Cod sursa (job #1061082)
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD=66617;
const int MAX_N=50100;
int h,w;
inline int hashF(int x,int y) {
x/=w;
y/=h;
return ((x%MOD)*327 + (y%MOD)*581)%MOD;
}
vector<int> H[MOD + 100];
pair<int,int> v[MAX_N];
bool intersect(int x,int y,int poz) {
return (x>=v[poz].first && x<=v[poz].first+w) && (y>=v[poz].second && y<=v[poz].second +h);
}
void getNum(int &x) {
char s[100];
scanf("%s",s);
x=0;
char *p=s;
while(*p>='0'&&*p<='9') {
x=x*10+(*p-'0');
p++;
}
}
int main() {
freopen("ograzi.in","r",stdin);
freopen("ograzi.out","w",stdout);
int n,m;
scanf("%d%d%d%d",&n,&m,&w,&h);
for(int i=1;i<=n;i++) {
getNum(v[i].first);
getNum(v[i].second);
H[ hashF( v[i].first , v[i].second) ].push_back(i);
H[ hashF( v[i].first + w , v[i].second) ].push_back(i);
H[ hashF( v[i].first , v[i].second + h) ].push_back(i);
H[ hashF( v[i].first + w , v[i].second + h) ].push_back(i);
}
int ans=0;
for(int i=1;i<=m;i++) {
int x,y;
getNum(x);
getNum(y);
for(vector<int>::iterator it=H[hashF(x,y)].begin(); it!=H[hashF(x,y)].end(); it++) {
if(intersect(x,y,*it)) {
ans++;
break;
}
}
}
printf("%d",ans);
return 0;
}