就是一个单纯的上凸壳
扫描法水过
#include<bits/stdc++.h>
using namespace std;
const int N=600000;
const double eps=1e-16;
struct Point{
double x,y;
int id;
Point(double _x=0.0,double _y=0.0):x(_x),y(_y){}
friend Point operator + (Point A,Point B){return Point(A.x+B.x,A.y+B.y);}
friend Point operator - (Point A,Point B){return Point(A.x-B.x,A.y-B.y);}
friend Point operator * (Point A,double k){return Point(A.x*k,A.y*k);}
friend Point operator / (Point A,double k){return Point(A.x/k,A.y/k);}
friend bool operator < (Point A,Point B){if(fabs(A.x-B.x)<eps)return A.y<B.y;else return A.x<B.x;}
void read(){scanf("%lf%lf",&x,&y);}
}p[N],convex_hull[N];
int n,top;
double Cross(Point A,Point B){
return (B.y-A.y)/(A.x-B.x);
}
//void Push(int now){
// while(Cross(p[now]-convex_hull[top-1],convex_hull[top]-convex_hull[top-1])>0)top--;
// top++;
// convex_hull[top]=p[now];
//}
void Push(int a)
{
while(top)
{
if(fabs(convex_hull[top].x-p[a].x)<eps)top--;
else if(top>1&&Cross(p[a],convex_hull[top-1])<=Cross(convex_hull[top],convex_hull[top-1]))
top--;
else break;
}
convex_hull[++top]=p[a];
}
void Make_Convex_Hull(){
convex_hull[0]=convex_hull[top=1]=p[1];
for(int i=2;i<=n;i++){
Push(i);
}
}
bool cmp(Point A,Point B){
return A.id<B.id;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
p[i].read();
p[i].id=i;
}
sort(p+1,p+1+n);
Make_Convex_Hull();
sort(convex_hull+1,convex_hull+1+top,cmp);
for(int i=1;i<=top;i++){
cout<<convex_hull[i].id<<" ";
}
}