Pagini recente » Castel3 | Profil sorinalupu | Cod sursa (job #2685040) | Profil noisyRam | Cod sursa (job #2008170)
#include <iostream>
#include<fstream>
#include<vector>
#include<cstring>
using namespace std;
const int mod=26459;
const int nmax=200005;
struct ograda
{
int l,c,x,y;
}aux;
char str[30];
vector<ograda> v[mod+5];
int key,i,j,n,m,xt,yt,xf,yf,ret,w,h,tot,ch,num,cadran,lin,col,xi,yi;
void ins()
{
aux.l=xf+1;aux.c=yf+1;aux.x=xt;aux.y=yt;
key=(aux.l*997+aux.c)%mod;
v[key].push_back(aux);
}
void finds(int lin,int col)
{
key=(lin*997+col)%mod;
for(int idx=0;idx<v[key].size();idx++)
{
if(v[key][idx].l==lin&&v[key][idx].c==col)
{
aux=v[key][idx];
ret=(aux.x<=xt&&aux.y<=yt&&aux.x+w>=xt&&aux.y+h>=yt);
return;
}
}
return;
}
int getnum()
{
num=0;
while(str[ch]>='0'&&str[ch]<='9')
{num=num*10+str[ch]-'0';ch++;}
ch++;
return num;
}
int main()
{
freopen("ograzi.in","r",stdin);
ofstream g("ograzi.out");
gets(str);
ch=0;
n=getnum();m=getnum();w=getnum();h=getnum();
for(i=1;i<=n;i++)
{
gets(str);
ch=0;
xt=getnum();yt=getnum();
xt++;yt++;
xf=xt/w;yf=yt/h;
ins();
}
for(i=1;i<=m;i++)
{
gets(str);
ch=0;
xt=getnum();yt=getnum();
xt++;yt++;
xf=xt/w;yf=yt/h;
ret=0;
for(j=0;j<4&&ret==0;j++)
{
finds(xf+j/2,yf+(j&1));
}
tot+=ret;
}
g<<tot;
return 0;
}