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

{
    "dijkstra  (信使)": {
        "prefix": "acm-3.1n^2",
        "body": [
            "#include<bits/stdc++.h>",
            "using namespace std;",
            "int i,j,ans,a,b,z,n,m,pan[110],w,mi,f[110][110],dis[110];",
            "int main(){",
            "    scanf(\"%d%d\",&n,&m);",
            "    for(i=1;i<=n;i++)",
            "        for(j=1;j<=n;j++)",
            "            f[i][j]=0xfffffff;",
            "    for(i=1;i<=n;i++)dis[i]=0xfffffff;",
            "    for(i=1;i<=m;i++){",
            "        scanf(\"%d%d%d\",&a,&b,&z);",
            "        f[a][b]=f[b][a]=z;",
            "    }",
            "    for(i=1;i<=n;i++)dis[i]=f[1][i];",
            "    dis[1]=0;pan[1]=1;",
            "    for(i=1;i<=n;i++){",
            "        w=0;mi=0xfffffff;",
            "        for(j=1;j<=n;j++)if(!pan[j]&&dis[j]<mi)mi=dis[w=j];",
            "        if(!w)break;pan[w]=1;",
            "        for(j=1;j<=n;j++)dis[j]=min(dis[j],dis[w]+f[w][j]);",
            "    }",
            "    for(i=1;i<=n;i++)ans=max(ans,dis[i]);",
            "    if(ans==0xfffffff)printf(\"-1\");",
            "    else printf(\"%d\",ans);",
            "    return 0;",
            "}",
            ""
        ],
        "description": "插入 dijkstra  (信使)"
    }
}