Pagini recente » Cod sursa (job #2309519) | Cod sursa (job #1599731) | Cod sursa (job #2684420) | Cod sursa (job #1839946) | Cod sursa (job #2025800)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n, m, w, h, sol;
unordered_map<int, pair <int, int> > have;
const int P = 1e9 + 7;
class InputReader {
public:
InputReader() {}
InputReader(const char *file_name) {
input_file = fopen(file_name, "r");
cursor = 0;
fread(buffer, SIZE, 1, input_file);
}
inline InputReader &operator >>(int &n) {
while(buffer[cursor] < '0' || buffer[cursor] > '9') {
advance();
}
n = 0;
while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
n = n * 10 + buffer[cursor] - '0';
advance();
}
return *this;
}
private:
FILE *input_file;
static const int SIZE = 1 << 17;
int cursor;
char buffer[SIZE];
inline void advance() {
++ cursor;
if(cursor == SIZE) {
cursor = 0;
fread(buffer, SIZE, 1, input_file);
}
}
};
int cod(int x, int y) {
return x * P + y;
}
void addHash(int x, int y) {
have[cod(x / w, y / h)] = {x, y};
}
bool inside(int a, int b, int c, int d, int x, int y) {
return x >= a && x <= c && y >= b && y <= d;
}
bool inHash(ll codN) {
return have.find(codN) != end(have);
}
int main() {
InputReader cin("ograzi.in");
ofstream cout("ograzi.out");
cin >> n >> m >> w >> h;
for(int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
addHash(x, y);
}
for(int i = 1; i <= m; ++i) {
int x, y;
cin >> x >> y;
int cx = x / w, cy = y / h;
vector <pair<int, int> > check;
check.emplace_back(cx, cy), check.emplace_back(cx - 1, cy);
check.emplace_back(cx, cy - 1), check.emplace_back(cx - 1, cy - 1);
for(auto it : check) {
ll itcod = cod(it.first, it.second);
if(inHash (itcod)) {
int chkx = have[itcod].first, chky = have[itcod].second;
if(inside(chkx, chky, chkx + w, chky + h, x, y)) {
++sol;
break;
}
}
}
}
cout << sol;
return 0;
}