Pagini recente » Cod sursa (job #1115809) | Cod sursa (job #947049) | Cod sursa (job #1840809) | Cod sursa (job #2032720) | Cod sursa (job #2328896)
#include <cstdio>
using namespace std;
int n,m;
int nr=0;
struct punct
{
int x,y;
}Vf[808];
punct Ext;
void citire()
{
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++)
scanf("%d %d",&Vf[i].x,&Vf[i].y);
}
long long determ(int x,int y,punct a,punct b)
{
long long f=((a.x-x)*(b.y-y)-(a.y-y)*(b.x-x));
return f;
}
void verif(int x,int y)
{
long long f1,f2;
int cont=0;
for(int i=1;i<n;i++)
{
f1=determ(x,y,Ext,Vf[i-1]);
f2=determ(x,y,Ext,Vf[i]);
if(f1>0 && f2<0)
cont++;
else if(f1<0 && f2>0)
cont++;
if(f1==0)
{
f1=determ(Vf[i].x,Vf[i].y,Vf[i-1],Ext);
f2=determ(x,y,Vf[i],Vf[i-1]);
if(f1>0 && f2<0)
cont++;
else if(f1<0 && f2>0)
cont++;
}
}
if(cont%2!=0)
nr++;
}
int main()
{
Ext.x=60005;
Ext.y=60005;
freopen("poligon.in","r",stdin);
freopen("poligon.out","w",stdout);
citire();
int x,y;
for(int i=0;i<m;i++)
{
scanf("%d %d",&x,&y);
verif(x,y);
}
printf("%d",nr);
return 0;
}