namespace ComputationGeometry{
const ld eps=1e-8,pi=acosl(-1.0);
struct vec{
ld x,y;
vec(ld X=0,ld Y=0){x=X;y=Y;}
void in(){scanf("%Lf%Lf",&x,&y);}
void out(){printf("%Lf %Lf\n",x,y);}
vec operator +(vec a){return (vec){x+a.x,y+a.y};}
vec operator -(vec a){return (vec){x-a.x,y-a.y};}
vec operator *(ld a){return (vec){x*a,y*a};}
vec operator /(ld a){return (vec){x/a,y/a};}
vec rotate(ld t){return (vec){x*cosl(t)+y*sinl(t),-x*sinl(t)+y*cosl(t)};}
vec rotate(vec a,ld t){return (vec){(x-a.x)*cosl(t)+(y-a.y)*sinl(t)+a.x,-(x-a.x)*sinl(t)+(y-a.y)*cosl(t)+a.y};}
bool operator ==(vec a){return (fabsl(x-a.x)<eps)&(fabsl(y-a.y)<eps);}
ld operator *(vec a){return x*a.y-y*a.x;}
ld operator ^(vec a){return x*a.x+y*a.y;}
ld len(){return sqrtl(x*x+y*y);}
};
ld slope(vec a,vec b){return (a.y-b.y)/(a.x-b.x);}
struct line{
vec p1,p2;
ld slope(){return (p1.y-p2.y)/(p1.x-p2.x);}
ld val_y(ld x){
int k=slope(),b=p1.y-p1.x*k;
return k*x+b;
}
ld val_x(ld y){
int k=slope(),b=p1.y-p1.x*k;
return (y-b)/k;
}
};
inline ld dis(vec a,vec b){return (a-b).len();}
inline ld dis_line(vec p,line a){return fabsl((p-a.p1)*(a.p2-a.p1)/((a.p1-a.p2).len()));}
bool pip_line(vec p,line a){return dis_line(p,a)<eps;}
bool cross(line a,line b){
ld t1=(a.p2-a.p1)*(b.p1-a.p1),t2=(a.p2-a.p1)*(b.p2-a.p1);
ld t3=(b.p2-b.p1)*(a.p1-b.p1),t4=(b.p2-b.p1)*(a.p2-b.p1);
return (t1*t2<eps)&(t3*t4<eps);
}
vec p_cross(line a,line b){
vec x=a.p2-a.p1,y=b.p2-b.p1,z=a.p1-b.p1;
return a.p1+x*((y*z)/(x*y));
}
bool cmp(vec a,vec b){
if(a.x==b.x) return a.y<b.y;
else return a.x<b.x;
}
void Convex(vec in[],vec out[],int &cnt){
int stk[N],top=0;bool vis[N];
sort(in+1,in+1+cnt,cmp);
stk[top=1]=1;
for(int i=2;i<=cnt;i++){
while(top>=2&&(in[i]-in[stk[top]])*(in[stk[top]]-in[stk[top-1]])<eps) vis[stk[top--]]=false;
vis[i]=true;stk[++top]=i;
}
int siz=top;
for(int i=cnt-1;i>=1;i--){
if(vis[i]) continue;
while(top>siz&&(in[i]-in[stk[top]])*(in[stk[top]]-in[stk[top-1]])<eps) vis[stk[top--]]=false;
vis[i]=true;stk[++top]=i;
}
for(int i=1;i<=top;i++) out[i]=in[stk[i]]; cnt=top;
}
}
using namespace ComputationGeometry;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?