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

{
    "最小环  (Sightseeing Trip)": {
        "prefix": "acm-3.1Floyed",
        "body": [
            "#include<algorithm>",
            "#include<cstdio>",
            "#define Re register int",
            "using namespace std;",
            "const int N=103,inf=1e8;",
            "int n,m,x,y,z,ans,Ans[N],a[N][N],g[N][N],dis[N][N];",
            "inline void in(Re &x){",
            "\tRe fu=0;x=0;char ch=getchar();",
            "\twhile(ch<'0'||ch>'9')fu|=ch=='-',ch=getchar();",
            "\twhile(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();",
            "\tx=fu?-x:x;",
            "}",
            "inline void get(Re i,Re j){",
            "\tRe k=g[i][j];if(!k)return;",
            "\tget(i,k),Ans[++Ans[0]]=k,get(k,j);",
            "}",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(n),in(m);",
            "\tfor(Re i=1;i<=n;++i)",
            "\t\tfor(Re j=1;j<=n;++j)",
            "\t\t\tdis[i][j]=a[i][j]=inf;",
            "\tfor(Re i=1;i<=n;++i)dis[i][i]=a[i][i]=0;",
            "\twhile(m--)in(x),in(y),in(z),dis[x][y]=dis[y][x]=a[x][y]=a[y][x]=min(a[x][y],z);",
            "\tans=inf;",
            "\tfor(Re k=1;k<=n;++k){",
            "\t\tfor(Re i=1;i<k;++i)",
            "\t\t\tfor(Re j=i+1,tmp;j<k;++j)\t",
            "\t\t\t\tif((tmp=dis[i][j]+a[j][k]+a[k][i])<ans){",
            "\t\t\t\t\tans=tmp,Ans[0]=0;",
            "\t\t\t\t\tAns[++Ans[0]]=i;",
            "\t\t\t\t\tget(i,j);",
            "\t\t\t\t\tAns[++Ans[0]]=j;",
            "\t\t\t\t\tAns[++Ans[0]]=k;",
            "\t\t\t\t}",
            "\t\tfor(Re i=1;i<=n;++i)",
            "\t\t\tfor(Re j=1,tmp;j<=n;++j)",
            "\t\t\t\tif((tmp=dis[i][k]+dis[k][j])<dis[i][j])\t",
            "\t\t\t\t\tdis[i][j]=tmp,g[i][j]=k;",
            "\t}",
            "\tif(ans==inf)puts(\"No solution.\");",
            "\telse for(Re i=1;i<=Ans[0];++i)printf(\"%d \",Ans[i]); ",
            "}",
            ""
        ],
        "description": "插入 最小环  (Sightseeing Trip)"
    }
}