//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-2.4并查集+生成树",
        "body": [
            "/*",
            "            ���� ",
            "           |   | ",
            "           |   | ",
            "           |   | ",
            "      ������     ������ ",
            "    |  ����ACʮ�ּ�   | ",
            "     ������      ������ ",
            "           |   | ",
            "           |   | ",
            "           |   | ",
            "            ���� ",
            "*/",
            "//#include<bits/stdc++.h>",
            "#include<cstdio>",
            "#include<cstdlib>",
            "#include<iostream>",
            "#include<algorithm>",
            "int n,m,k,f[40001],sum;",
            "struct sakura{",
            "\tint p,a,b,val;",
            "}sak[40001];",
            "inline int find(int x){return f[x]==x?x:find(f[x]);}",
            "inline bool cmp(const sakura &a,const sakura &b){return a.val<b.val;}",
            "inline bool unions(int x,int y){",
            "\tint fx=find(x),fy=find(y);",
            "\tif(fx==fy) return 0;",
            "\telse f[fy]=fx;",
            "\treturn 1;",
            "}",
            "int main(){",
            "\tscanf(\"%d%d\",&n,&m);",
            "\tfor(int i=1;i<=n;i++) f[i]=i;",
            "\tfor(int i=1;i<=m;i++)",
            "\t\tscanf(\"%d%d%d\",&sak[i].a,&sak[i].b,&sak[i].val);",
            "\tstd::sort(sak+1,sak+1+m,cmp);",
            "\tfor(int i=1;i<=m;i++){",
            "\t\tif(unions(sak[i].a,sak[i].b)){",
            "\t\t\tk++;",
            "\t\t\tsum=sak[i].val;",
            "\t\t}",
            "\t\tif(k==n-1) break;",
            "\t}",
            "\tprintf(\"%d %d\",n-1,sum);",
            "\treturn 0;",
            "} ",
            ""
        ],
        "description": "插入 繁忙的都市"
    }
}