//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-6.5工艺",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define LL long long",
            "#define Re register int",
            "using namespace std;",
            "const int N=3e5+5;",
            "int n,s[N<<1];",
            "inline void in(Re &x){",
            "    Re f=0;x=0;char c=getchar();",
            "    while(c<'0'||c>'9')f|=c=='-',c=getchar();",
            "    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();",
            "    x=f?-x:x;",
            "}",
            "int main(){",
            "\tin(n);",
            "\tfor(Re i=1;i<=n;++i)in(s[i]),s[i+n]=s[i];",
            "\tRe i=1,j=2;",
            "\twhile(i<=n&&j<=n){",
            "\t\tRe k=1;",
            "\t\twhile(k<=n&&s[i+k-1]==s[j+k-1])++k;",
            "\t\tif(k>n)break;",
            "\t\tif(s[i+k-1]>s[j+k-1])i+=k;",
            "\t\telse j+=k;",
            "\t\tif(i==j)++i;",
            "\t}",
            "\tRe st=min(i,j);",
            "\tfor(Re i=0;i<n;++i)printf(\"%d \",s[st+i]);",
            "}",
            ""
        ],
        "description": "插入 最小表示法"
    }
}