Cod sursa(job #908999)

Utilizator FayedStratulat Alexandru Fayed Data 10 martie 2013 13:40:26
Problema Ograzi Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.55 kb
#include <cstdio>
#include <cstring>
#define NMAX 50001
#define MMAX 100001
using namespace std;

struct Oaie{
    int x,y;
        }Oita[MMAX];

struct Ograda{
    int x,y;
        }Ograd[NMAX];

int N,M,L,H,Nmax;
char cc[16];

inline void citesc(){

    int ii=0,X=0,Y=0;
    freopen("ograzi.in","r",stdin);
    freopen("ograzi.out","w",stdout);
    scanf("%d%d%d%d",&N,&M,&L,&H);
       fgets(cc,sizeof(cc),stdin);

        for(register int i=1;i<=N;++i){
            ii=0,X=0,Y=0;
             fgets(cc,sizeof(cc),stdin);

                while(cc[ii]>='0' && cc[ii] <='9')
                X = X*10 + cc[ii++]-'0';
                ii++;
                Ograd[i].x = X;
                 while(cc[ii]>='0' && cc[ii] <='9')
                Y = Y*10 + cc[ii++]-'0';
                Ograd[i].y = Y;
        }

        for(register int i=1;i<=M;++i){
            ii = 0, X = 0, Y = 0;
            fgets(cc,sizeof(cc),stdin);
             while(cc[ii]>='0' && cc[ii] <='9')
            X = X*10 + cc[ii++]-'0';
            ii++;
            Oita[i].x = X;
             while(cc[ii]>='0' && cc[ii] <='9')
            Y = Y*10 + cc[ii++]-'0';
            Oita[i].y = Y;
        }
}

inline void solve(){

    Nmax = M;
    for(register int i=1;i<=N;++i)
        for(register int j=1;j<=M;++j)
            if(Oita[j].x <= Ograd[i].x +H && Oita[j].x >= Ograd[i].x && Oita[j].y <= Ograd[i].y +L && Oita[j].y >= Ograd[i].y)
                Nmax--;

    printf("%d",Nmax);
}

int main(){

    citesc();
    solve();

return 0;
}