Pagini recente » Cod sursa (job #1038104) | Cod sursa (job #2753451) | Cod sursa (job #828205) | Cod sursa (job #1857146) | Cod sursa (job #2328866)
#include <cstdio>
const int N_MAX = 800;
const int M_MAX = 60000;
struct Punct{
int x,y;
};
int n,m;
Punct poligon[N_MAX],infractiuni[M_MAX];
Punct E = {-1,-1};
void read(){
scanf("%d %d",&n,&m);
// printf("%d %d\n",n,m);
for(int i=0; i<n;++i){
int x,y;
scanf("%d %d",&x,&y);
poligon[i].x = x;
poligon[i].y = x;
}
for(int i=0; i<m;++i){
int x,y;
scanf("%d %d",&x,&y);
infractiuni[i].x = x;
infractiuni[i].y = x;
}
}
int determinant(Punct A,Punct B,Punct C){
return (B.x - A.x)*(C.y-A.y)-(C.x-A.x)*(B.y-A.y);
}
bool parte(Punct A,Punct B,Punct P){
if(determinant(A,B,P)*determinant(A,B,E)<=0) return true;
return false;
}
void solve(){
int rez;
rez =0;
for(int i=0;i<m;++i){
int intersectie;
intersectie = 0;
for (int j = 0; j < n-1; ++j) {
if(parte(poligon[j],poligon[j+1],infractiuni[i])){
++intersectie;
}
}
// printf("%d\n",intersectie);
if(intersectie%2){
++rez;
}
}
printf("%d",rez-1);
}
int main() {
freopen("poligon.in","r",stdin);
freopen("poligon.out","w",stdout);
read();
solve();
return 0;
}