Cod sursa(job #1199735)
Utilizator | Data | 20 iunie 2014 14:27:21 | |
---|---|---|---|
Problema | Ograzi | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.72 kb |
#include <fstream>
using namespace std;
ifstream cin("ograzi.in");
ofstream cout("ograzi.out");
typedef struct celula {
long poz;
celula* next;
}*lista;
typedef struct punct {
long x;
long y;
};
void add(long var, lista &p)
{
lista r= new celula;
r->poz=var;
r->next=p;
p=r;
}
lista Hash[10^6+1],r;
punct D[5*10^5];
long i,n,a,b,m,w,h,sol(0),j,lmax,hmax;
int main()
{
cin>>n>>m>>w>>h;
for (i=1;i<=n;++i)cin>>D[i].x>>D[i].y;
for (i=1;i<=m;++i){
cin>>a>>b;
add(b,Hash[a]);
}
for (i=1;i<=n;++i) {
lmax=w+D[i].x;
hmax=h+D[i].y;
for (j=D[i].x;j<=lmax;++j)
{
r=Hash[j];
while (r) {
if ((r->poz<=hmax) && (r->poz>=D[i].y)) {
++sol;
delete r;
}
r=r->next;
}
}
}
cout<<sol<<"\n";
return 0;
}