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

{
    "Trie树": {
        "prefix": "acm-6.3于是他错误的点名开始了",
        "body": [
            "#pragma once",
            "#include<cstring>",
            "#include<cstdio>",
            "#define R register int",
            "using namespace std;",
            "const int SP=500003;",
            "int trie[SP][26],pan[SP],ed[SP],re,t=1,n;",
            "char ch[55];",
            "inline void add(char ch[]){",
            "    R a,i=0,p=1,m=strlen(ch);",
            "    for(;i<m;i++){",
            "        a=ch[i]-'a';",
            "        if(!trie[p][a])trie[p][a]=++t;",
            "        p=trie[p][a];",
            "    }",
            "    ed[p]=1;",
            "}",
            "inline int find(char ch[]){",
            "    R re,i=0,p=1,m=strlen(ch);",
            "    for(;i<m;i++){",
            "        p=trie[p][ch[i]-'a'];",
            "        if(!p)return 0;",
            "    }",
            "    re=ed[p];",
            "    if(ed[p])ed[p]++;",
            "    return re;",
            "}",
            "int main(){",
            "    scanf(\"%d\",&n);",
            "    while(n--){scanf(\"%s\",ch);add(ch);}",
            "    scanf(\"%d\",&n);",
            "    while(n--){",
            "        scanf(\"%s\",ch);",
            "        re=find(ch);",
            "        if(!re)printf(\"WRONG\\n\");",
            "        else if(re==1)printf(\"OK\\n\");",
            "        else printf(\"REPEAT\\n\");",
            "    }",
            "}",
            ""
        ],
        "description": "插入 Trie树"
    }
}