Cod sursa(job #3291782)

Utilizator CosminaneBoac Mihai Cosmin Cosminane Data 5 aprilie 2025 16:46:42
Problema Ograzi Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.78 kb
#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;
}