Pagini recente » Cod sursa (job #979910) | Cod sursa (job #188394) | Cod sursa (job #1458850) | Cod sursa (job #2418910) | Cod sursa (job #3291782)
#include <fstream>
#include <unordered_map>
#include <vector>
using namespace std;
struct elem{
int x, y;
};
unordered_map <int, unordered_map <int, int>> f;
vector <elem> v;
int w, h;
bool check(int x, int y, int poz){
if( v[poz].x + w >= x && v[poz].y + h >= y ){
return true;
}
return false;
}
int main(){
int n, m, i, x, y, r;
ifstream fin( "ograzi.in" );
ofstream fout( "ograzi.out" );
fin >> n >> m >> w >> h;
for( i = 0; i < n; i++ ){
fin >> x >> y;
v.push_back( { x, y } );
f[x / w][y / h] = i;
}
r = 0;
for( i = 0; i < m; i++ ){
fin >> x >> y;
r += max( { check( x, y, f[x / w][y / h] ), check( x, y, f[x / w - 1][y / h] ), check( x, y, f[x / w][y / h - 1] ), check( x, y, f[x / w - 1][y / h - 1] ) } );
}
fout << r;
return 0;
}