Pagini recente » Cod sursa (job #2111659) | Cod sursa (job #2422223) | Cod sursa (job #2938670) | Cod sursa (job #1054399) | Cod sursa (job #2628829)
#include <bits/stdc++.h>
#define maxn 100005
#define dmax 293939
FILE *fin;
std::ofstream fout ("ograzi.out");
int current = 4047;
char buffer[4048];
char getChar (){
current ++;
if (current == 4048){
current = 0;
fread (buffer, 1, 4048, fin);
}
return buffer[current];
}
void read(int &number){
char chr = getChar();
number = 0;
while ('0' <= chr and chr <= '9'){
number = number * 10 + (chr - '0');
chr = getChar();
}
}
int X[maxn], Y[maxn];
std::vector <int> v[dmax];
int sol = 0, lx, ly, x, y;
void check (int a, int b){
int p = (97*a+b)%dmax;
if (v[p].empty() == false){
for (auto i:v[p]){
if (X[i] <= x and x <= X[i]+lx and Y[i] <= y and y <= Y[i]+ly)
sol ++;
}
}
}
int main()
{
fin = fopen("ograzi.in", "r");
int A, S, i, p, a, b;
read(A); read(S); read(lx); read(ly);
for (i=0; i<A; i++){
read (X[i]); read(Y[i]);
a = (X[i] + lx - 1) / lx;
b = (Y[i] + ly - 1) / ly;
v[(97*a+b)%dmax].push_back (i);
}
for (i=0; i<S; i++){
read(x); read(y);
a = (x + lx - 1) / lx;
b = (y + ly - 1) / ly;
check (a, b);
check (a-1, b);
check (a, b-1);
check (a-1, b-1);
}
fout << sol << '\n';
return 0;
}