//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-4.3普通无向图",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#include<queue>",
            "#define LL long long",
            "#define Re register int",
            "using namespace std;",
            "const int N=103,M=503;",
            "int n,m,o,x,y,z,K,ans,pan[N],head[N],dp[N][1024+3];queue<int>Q;",
            "struct QAQ{int w,to,next;}a[M<<1];",
            "inline void add(Re x,Re y,Re z){a[++o].w=z,a[o].to=y,a[o].next=head[x],head[x]=o;}",
            "inline void in(Re &x){",
            "    int 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;",
            "}",
            "inline void SPFA(Re s){",
            "\twhile(!Q.empty()){",
            "\t\tRe x=Q.front();Q.pop();pan[x]=0;",
            "\t\tfor(Re i=head[x],to;i;i=a[i].next)",
            "\t\t\tif(dp[x][s]+a[i].w<dp[to=a[i].to][s]){",
            "\t\t\t\tdp[to][s]=dp[x][s]+a[i].w;",
            "\t\t\t\tif(!pan[to])Q.push(to),pan[to]=1;",
            "\t\t\t}",
            "\t}",
            "}",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(n),in(m),in(K);",
            "\twhile(m--)in(x),in(y),in(z),add(x,y,z),add(y,x,z);",
            "\tmemset(dp,63,sizeof(dp));Re inf=dp[0][0];",
            "\tfor(Re i=1;i<=K;++i)in(x),dp[x][1<<i-1]=0,ans=x;",
            "\tRe V=(1<<K)-1;",
            "\tfor(Re s=0;s<=V;++s){",
            "\t\tfor(Re i=1;i<=n;++i){",
            "\t\t\tfor(Re t=(s-1)&s;t;t=(t-1)&s)",
            "\t\t\t\tdp[i][s]=min(dp[i][s],dp[i][t]+dp[i][s^t]);",
            "\t\t\tif(dp[i][s]!=inf)Q.push(i),pan[i]=1;",
            "\t\t}",
            "\t\tSPFA(s);",
            "\t}",
            "\tprintf(\"%d \",dp[ans][V]);",
            "}",
            ""
        ],
        "description": "插入 斯坦纳树"
    }
}