//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 的格式要求是 "插入 [该代码片段的中文名]"

{
    "Necklace": {
        "prefix": "acm-6.5最小表示法判断同构",
        "body": [
            "#include<cstring>",
            "#include<cstdio>",
            "int i,j,k,n,m,x,y,st;char a[2000003],b[2000003];",
            "inline int sakura(char a[]){",
            "    i=1,j=2;",
            "    while(i<=n&&j<=n){",
            "        k=0;",
            "        while(k<n&&a[i+k]==a[j+k])++k;",
            "        if(k==n)break;",
            "        if(a[i+k]>a[j+k]){i+=k+1;if(i==j)++i;}",
            "        else{j+=k+1;if(i==j)++j;}",
            "    }",
            "    return i<j?i:j;",
            "}",
            "inline int judge(char a[],char b[]){",
            "    n=strlen(a+1);",
            "    for(i=1;i<=n;++i)a[i+n]=a[i],b[i+n]=b[i];",
            "    x=sakura(a),y=sakura(b);",
            "    a[x+n]=b[y+n]='\\0';",
            "    return !strcmp(a+x,b+y);",
            "}",
            "int main(){",
            "    scanf(\"%s%s\",a+1,b+1);",
            "    if(judge(a,b)){printf(\"Yes\\n\");puts(a+x);}",
            "    else printf(\"No\");",
            "}",
            ""
        ],
        "description": "插入 Necklace"
    }
}