Pagini recente » Istoria paginii runda/simulare_oji_2023_clasa_9_16_martie | Profil foroji2019 | Cod sursa (job #1126082) | Cod sursa (job #1742074) | 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;
}