2 //any problem please send mail to me: lihe21327@gmail.com (also gtalk)
4 double det(point a
,point b
,point c
)
5 {return (b
.x
-a
.x
)*(c
.y
-a
.y
)-(b
.y
-a
.y
)*(c
.x
-a
.x
);}
6 double dis(point a
,point b
)
7 {return (a
.x
-b
.x
)*(a
.x
-b
.x
)+(a
.y
-b
.y
)*(a
.y
-b
.y
);}
8 void swap(point
&a
,point
&b
)
9 {point tt
;tt
=a
,a
=b
,b
=tt
;}
10 bool cmp(const point
&a
,const point
&b
)
12 if(fabs(det(p
[0],a
,b
))<eps
)
13 return dis(p
[0],a
)<dis(p
[0],b
);
14 return det(p
[0],a
,b
)>0;
18 void Convex_Hull(point
*p
,long n
,point
*stack
,long& top
)
22 if(p
[i
].y
<p
[0].y
||fabs(p
[i
].y
-p
[0].y
)<eps
&&p
[i
].x
<p
[0].x
)
28 while(top
>=2&&det(stack
[top
-2],stack
[top
-1],p
[i
])<=0)