Cod sursa(job #3363890)

Utilizator cristiz123456Zoescu Cristian cristiz123456 Data 24 august 2026 18:52:44
Problema Ograzi Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <bits/stdc++.h>
using namespace std;
int w, h;
map <pair<int, int>, pair<int, int>> dp;
bool check(int i, int j, int x, int y)
{
    auto[lin, col] = dp[{i, j}];
    if(x >= lin && x <= lin + w && y >= col && y <= col + h)
        return true;
    return false;
}
int main()
{
    ifstream cin("ograzi.in");
    ofstream cout("ograzi.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, i, j, x, y, k, oi = 0;
    cin >> n >> m >> w >> h;
    for(i = 0; i < n; i++)
    {
        cin >> x >> y;
        dp[{x / w, y / h}] = {x, y};
    }
    for(k = 0; k < m; k++)
    {
        cin >> x >> y;
        i = x / w;
        j = y / h;
        if(check(i, j, x, y) == true || check(i - 1, j, x, y) == true || check(i - 1, j - 1, x, y) == true || check(i, j - 1, x, y) == true)
            oi++;
    }
    cout << oi;
    return 0;
}