@[柠檬布丁吖](/user/370648) cmp的时候,你写了a.y<a.y。这里错了
by mmdxmakioi @ 2023-05-26 20:37:47
@[柠檬布丁吖](/user/370648)
```cpp
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+55;
struct point{
double x,y;
}p[maxn],s[maxn];
int n,top;
bool cmp(point a,point b){
return a.x!=b.x ? a.x<b.x : a.y<b.y;
}
double cross(point a,point b,point c){
return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}
double dis(point a,point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double andrew(){
sort(p+1,p+n+1,cmp);
for(int i=1;i<=n;i++){
while(top>1&&cross(s[top-1],s[top],p[i])<=0) top--;
s[++top]=p[i];
}
int t=top;
for(int i=n-1;i>=1;i--){
while(top>t&&cross(s[top-1],s[top],p[i])<=0) top--;
s[++top]=p[i];
}
double res=0;
for(int i=1;i<top;i++){
res+=dis(s[i],s[i+1]);
}
return res;
}
signed main(void){
cin>>n;
for(int i=1;i<=n;i++){
cin>>p[i].x>>p[i].y;
}
printf("%.2lf\n", andrew());
return 0;
}
```
by CEFqwq @ 2023-12-31 13:40:40