Cod sursa(job #2709581)

Utilizator marcumihaiMarcu Mihai marcumihai Data 20 februarie 2021 14:39:48
Problema Ograzi Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <bits/stdc++.h>
#define mod 100003
using namespace std;

ifstream f ("ograzi.in");
ofstream g ("ograzi.out");

vector <pair<int,int> > v[100005];
int n,m,w,h;
int rasp;
void cauta (int loc, int x, int y)
{
    if(loc<0)
        return;
    for(int i=0; i<v[loc].size(); ++i)
    {
        if(v[loc][i].first<=x && x<=v[loc][i].first+w && v[loc][i].second<=y && y<=v[loc][i].second+h )
        {
            ++rasp;
        }
    }



}
int main()
{
    f>>n>>m>>w>>h;
    for(int i=1; i<=n; ++i)
    {
        int x, y;
        f>>x>>y;
        x=(x-1)/w+1;
        y=(y-1)/h+1;
        v[(x*100+y)%mod].push_back({x,y});
    }
    for(int i=1; i<=m; ++i)
    {
        int x,y;
        f>>x>>y;
        x=(x-1)/w+1;
        y=(y-1)/h+1;
        cauta((x*100+y)%mod, x, y);
        cauta((x*100+y-1)%mod, x, y);
        cauta(((x+1)*100+y)%mod, x,y);
        cauta(((x+1)*100+y-1)%mod, x, y );

    }
    g<<rasp;
    return 0;
}