//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "二维凸包": {
        "prefix": "acm-8.3周长",
        "body": [
            "#include<algorithm>",
            "#include<cstdio>",
            "#include<cmath>",
            "#define LD double",
            "#define Vector Point",
            "#define Re register int",
            "using namespace std;",
            "const int N=1e4+3;",
            "const LD eps=1e-8;",
            "inline int dcmp(LD a){return a<-eps?-1:(a>eps?1:0);}",
            "struct Point{LD x,y;Point(LD X=0,LD Y=0):x(X),y(Y){}}Poi[N],cp[N];",
            "inline LD Dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}",
            "inline LD Cro(Vector a,Vector b){return a.x*b.y-a.y*b.x;}",
            "inline LD Len(Vector a){return sqrt(Dot(a,a));}",
            "inline LD Angle(Vector a,Vector b){return acos(Dot(a,b)/Len(a)/Len(b));}",
            "inline Vector Normal(Vector a){LD L=Len(a);return Vector(-a.y/L,a.x/L);}",
            "inline Vector operator+(Vector a,Vector b){return Vector(a.x+b.x,a.y+b.y);}",
            "inline Vector operator-(Vector a,Vector b){return Vector(a.x-b.x,a.y-b.y);}",
            "inline Vector operator*(Vector a,LD b){return Vector(a.x*b,a.y*b);}",
            "inline Vector operator/(Vector a,LD b){return Vector(a.x/b,a.y/b);}",
            "inline bool cmp1(Vector a,Vector b){return a.x==b.x?a.y<b.y:a.x<b.x;};",
            "inline bool cmp2(Vector a,Vector b){",
            "\tLD pan=Cro(a-Poi[0],b-Poi[0]);",
            "\treturn pan>0||(pan==0&&Len(a-Poi[0])<Len(b-Poi[0]));",
            "};",
            "inline int ConvexHull(Point *P,Re n,Point *cp){",
            "\tsort(P+1,P+n+1,cmp1);",
            "\tRe t=0;",
            "\tfor(Re i=1;i<=n;++i){",
            "\t\twhile(t>1&&dcmp(Cro(cp[t]-cp[t-1],P[i]-cp[t-1]))<=0)--t;",
            "\t\tcp[++t]=P[i];",
            "\t}",
            "\tRe St=t;",
            "\tfor(Re i=n-1;i>=1;--i){",
            "\t\twhile(t>St&&dcmp(Cro(cp[t]-cp[t-1],P[i]-cp[t-1]))<=0)--t;",
            "\t\tcp[++t]=P[i];",
            "\t}",
            "\treturn --t;",
            "}",
            "int n;LD ans;",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tscanf(\"%d\",&n);",
            "\tfor(Re i=1;i<=n;++i)scanf(\"%lf%lf\",&Poi[i].x,&Poi[i].y);",
            "\tRe cnt=ConvexHull(Poi,n,cp);",
            "\tfor(Re i=1;i<=cnt;++i)ans+=Len(cp[i<cnt?i+1:1]-cp[i]);",
            "\tprintf(\"%.2lf\\n\",ans);",
            "}",
            ""
        ],
        "description": "插入 二维凸包"
    }
}