//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-3.3Redundant Paths",
        "body": [
            "#include<algorithm>",
            "#include<cstdio>",
            "#define Re register int",
            "using namespace std;",
            "const int N=5003,M=10003;",
            "int n,m,x,y,Q_o,leaf,ip[N],du[N];",
            "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;",
            "}",
            "struct Tarjan{",
            "\tint o,dfn_o,dfn[N],low[N],head[N],bridge[M<<1];",
            "\tstruct QAQ{int to,next;}a[M<<1];",
            "\tinline void add(Re x,Re y){a[++o].to=y,a[o].next=head[x],head[x]=o;}",
            "\tinline void tarjan(Re x,Re p){",
            "\t\tdfn[x]=low[x]=++dfn_o;",
            "\t\tfor(Re i=head[x],to;i;i=a[i].next)",
            "\t\t\tif(!dfn[to=a[i].to]){",
            "\t\t\t\ttarjan(to,i);",
            "\t\t\t\tlow[x]=min(low[x],low[to]);",
            "\t\t\t\tif(low[to]>dfn[x])bridge[i]=bridge[i^1]=1;",
            "\t\t\t}",
            "\t\t\telse if(i!=(p^1))low[x]=min(low[x],dfn[to]);",
            "\t}",
            "\tinline void dfs(Re x){",
            "\t\tip[x]=Q_o;",
            "\t\tfor(Re i=head[x];i;i=a[i].next)",
            "\t\t\tif(!ip[a[i].to]&&!bridge[i])dfs(a[i].to);",
            "\t}",
            "\tinline void SuoPoint(){",
            "\t\tfor(Re i=1;i<=n;++i)if(!dfn[i])tarjan(i,-1);",
            "\t\tfor(Re i=1;i<=n;++i)if(!ip[i])++Q_o,dfs(i);",
            "\t}",
            "}T1;",
            "int main(){",
            "    in(n),in(m),T1.o=1;",
            "    while(m--)in(x),in(y),T1.add(x,y),T1.add(y,x);",
            "    T1.SuoPoint();",
            "    for(Re i=2;i<=T1.o;i+=2)",
            "    \tif((x=ip[T1.a[i].to])!=(y=ip[T1.a[i^1].to]))++du[x],++du[y];",
            "    for(Re i=1;i<=Q_o;++i)leaf+=(du[i]==1);",
            "    printf(\"%d\",leaf+1>>1);",
            "}",
            ""
        ],
        "description": "插入 缩点—边双连通分量"
    }
}