其实就是普通的凸包。
模板在手,一生无忧。。。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define DOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define oo 1e6
#define eps 1e-8
#define nMax 100000
#define pb push_back
#define F first
#define S second
#define bug puts("OOOOh.....");
#define zero(x) (((x)>0?(x):-(x))<eps)
int dcmp(double x){
if(fabs(x)<eps) return 0;
return x>0?1:-1;
}
class point {
public:
double x,y;
point (double x=0,double y=0):x(x),y(y) {}
void make(double _x,double _y) {x=_x;y=_y;}
void read() { scanf("%lf%lf",&x,&y); }
void out() { printf("(%.0f,%.0f)\n",x,y);}
double len() { return sqrt(x*x+y*y); }
point friend operator - (point const& u,point const& v) {
return point(u.x-v.x,u.y-v.y);
}
point friend operator + (point const& u,point const& v) {
return point(u.x+v.x,u.y+v.y);
}
double friend operator * (point const& u,point const& v) {
return u.x*v.y-u.y*v.x;
}
double friend operator ^ (point const& u,point const& v) {
return u.x*v.x+u.y*v.y;
}
point friend operator * (point const& u,double const& k) {
return point(u.x*k,u.y*k);
}
friend bool operator < (point const& u,point const& v){
if(dcmp(v.x-u.x)==0) return dcmp(u.y-v.y)<0;
return dcmp(u.x-v.x)<0;
}
};
typedef class line{
public:
point a,b;
line() {}
line (point a,point b):a(a),b(b){}
void make(point u,point v) {a=u;b=v;}
void read() { a.read(),b.read(); }
}segment;
int ConvexHull(point *p,int n,point *ret){
sort(p,p+n);
int m=0;
for(int i=0;i<n;i++){
while(m>1 && dcmp((ret[m-1]-ret[m-2])*(p[i]-ret[m-1]))<0) m--;
ret[m++]=p[i];
}
int k=m;
for(int i=n-2;i>=0;i--) {
while(m>k && dcmp((ret[m-1]-ret[m-2])*(p[i]-ret[m-1]))<0) m--;
ret[m++]=p[i];
}
if(n>1) m--;
return m;
}
point p[nMax],q[nMax];
int n;
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
n=0;
while(~scanf("%lf%lf",&p[n].x,&p[n].y)) n++;
int m=ConvexHull(p,n,q);
int l;
for(l=0;l<m;l++) if(dcmp(q[l].x-0)==0 && dcmp(q[l].y-0)==0) break;
for(int i=0;i<m;i++) q[(i+l)%m].out();
return 0;
}