//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": [
            "#include<cstdio>",
            "#include<iostream> ",
            "using namespace std;// 找图的最小环 ",
            "int minn=0x7fffff,n,f[200005],d[200005];",
            "inline int min(int a,int b){if(a>b) return b;else return a;}",
            "",
            "inline int find(int x){",
            "\tif(f[x]!=x){",
            "\t\tint l=f[x];",
            "\t\tf[x]=find(f[x]);",
            "\t\td[x]+=d[l];",
            "\t}",
            "\treturn f[x];",
            "}",
            "",
            "inline void sakura(int a,int b){",
            "\tint aa=find(a);int bb=find(b);",
            "\tif(aa!=bb){",
            "\t\tf[aa]=bb;",
            "\t\td[a]=d[b]+1;",
            "\t}",
            "\telse",
            "\t\tminn=min(minn,d[a]+d[b]+1);",
            "}",
            "",
            "int main(){",
            "\tscanf(\"%d\",&n);",
            "\tfor(int i=1;i<=n;i++) f[i]=i;",
            "\tfor(int i=1;i<=n;i++){",
            "\t\tint x;",
            "\t\tscanf(\"%d\",&x);",
            "\t\tsakura(i,x);",
            "\t}",
            "\tprintf(\"%d\",minn);",
            "\treturn 0;",
            "}",
            "",
            ""
        ],
        "description": "插入 信息传递"
    }
}