int TuBao(P p[],int n,P q[]){
int m = 0;
sort(p,p+n);
for(int i=0;i<n;++i) {
while (m>1 && dcmp(cross(q[m-2],q[m-1],p[i]))<=0) m--;
q[m++] = p[i];
}
int k = m;
for(int i=n-2;i>=0;--i){
while(m>k && dcmp(cross(q[m-2],q[m-1],p[i]))<=0) m--;
q[m++] = p[i];
}
for(int i=0;i<m;++i) p[i] = q[i];
if(n>1)m--;
return m;
}
模板,凸包
最新推荐文章于 2022-04-25 08:20:17 发布