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

{
    "KMP": {
        "prefix": "acm-6.1kmp",
        "body": [
            "#include<iostream>",
            "#include<cstdio>",
            "#include<string>",
            "using namespace std;",
            "int i,j,n,m,next[1000005];string a,b;",
            "int main(){",
            "\tcin>>a>>b;",
            "\tn=a.size();a='$'+a;",
            "\tm=b.size();b='$'+b;",
            "\tfor(i=2,j=0;i<=m;i++){",
            "\t\twhile(j&&b[i]!=b[j+1])j=next[j];",
            "\t\tif(b[i]==b[j+1])j++;",
            "\t\tnext[i]=j;",
            "\t}",
            "\tfor(i=1,j=0;i<=n;i++){",
            "\t\twhile(j&&a[i]!=b[j+1])j=next[j];",
            "\t\tif(a[i]==b[j+1])j++;",
            "\t\tif(j==m){j=next[j];printf(\"%d\\n\",i-m+1);}",
            "\t}",
            "\tfor(i=1;i<=m;i++)printf(\"%d \",next[i]);",
            "}",
            ""
        ],
        "description": "插入 KMP"
    }
}