//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.6PAM",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define LL long long",
            "#define Re register int",
            "using namespace std;",
            "const int N=3e5+5;",
            "char s[N];",
            "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;",
            "}",
            "struct Palindromic_Automaton{",
            "\tint O,last,siz[N],len[N],fail[N],trans[N][26];",
            "\tPalindromic_Automaton(){O=1,len[1]=-1,fail[0]=fail[1]=last=1;}",
            "\tinline int find(Re p,Re id){while(s[id-1-len[p]]!=s[id])p=fail[p];return p;}",
            "\tinline void insert(Re ch,Re id){",
            "\t\tRe cur=find(last,id),now=trans[cur][ch];",
            "\t\tif(!now){",
            "\t\t\tnow=++O,len[now]=len[cur]+2;",
            "\t\t\tfail[now]=trans[find(fail[cur],id)][ch];",
            "\t\t\ttrans[cur][ch]=now;",
            "\t\t}",
            "\t\t++siz[now],last=now;",
            "\t}",
            "\tinline void sakura(){",
            "\t\tLL ans=0;",
            "\t\tfor(Re i=O;i>=2;--i)siz[fail[i]]+=siz[i],ans=max(ans,(LL)siz[i]*len[i]);",
            "\t\tprintf(\"%lld\\n\",ans);",
            "\t}",
            "}PAM;",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tscanf(\"%s\",s+1);",
            "\tfor(Re i=1;s[i];++i)PAM.insert(s[i]-'a',i);",
            "\tPAM.sakura();",
            "}",
            ""
        ],
        "description": "插入 回文串"
    }
}