凸包算法
http://poj.org/problem?id=3348
#include<cstdio> #include<algorithm> using namespace std; const int N=5e5+11; int n,m; struct point{ int x,y; point(){} point(int _x,int _y): x(_x),y(_y){} friend inline point operator -(const point A,const point B){ return point(A.x-B.x,A.y-B.y); } friend inline int operator *(const point A,const point B){ return A.x*B.y-A.y*B.x; } inline int norm(){ return x*x+y*y; } }p[N],q[N]; inline bool operator <(const point A,const point B){ int det=(A-p[1])*(B-p[1]); if(det!=0)return det>0; return (A-p[1]).norm()<(B-p[1]).norm(); } inline void Graham(){ int id=1; for(register int i=2;i<=n;++i) if(p[i].x<p[id].x||p[i].x==p[id].x&&p[i].y<p[id].y) swap(p[i],p[id]); sort(p+2,p+n+1); q[++m]=p[1]; for(register int i=2;i<=n;++i){ while(m>=2&&(p[i]-q[m-1])*(q[m]-q[m-1])>=0)--m; q[++m]=p[i]; } } inline int Area(){ int res=0; q[m+1]=q[1]; for(register int i=1;i<=m;++i) res+=q[i]*q[i+1]; return (res>>1); } int main(){ scanf("%d",&n); for(register int i=1;i<=n;++i)scanf("%d%d",&p[i].x,&p[i].y); Graham(); printf("%d\n",Area()/50); return 0; }