//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.3旅游航道",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define Re register int",
            "using namespace std;",
            "const int N=3e4+3,M=3e4+3;",
            "int n,m,x,y,ans;",
            "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 CL(){",
            "\t\tmemset(bridge,0,sizeof(bridge));",
            "\t\tmemset(head,0,sizeof(head));",
            "\t\tmemset(low,0,sizeof(low));",
            "\t\tmemset(dfn,0,sizeof(dfn));",
            "\t\tdfn_o=ans=0,o=1;",
            "\t}",
            "\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,++ans;",
            "\t\t\t}",
            "\t\t\telse if(i!=(p^1))low[x]=min(low[x],dfn[to]);",
            "\t}",
            "\tinline void get_bridg(){for(Re i=1;i<=n;++i)if(!dfn[i])tarjan(i,-1);}",
            "}T1;",
            "int main(){",
            "    while(scanf(\"%d%d\",&n,&m)&&n&&m){",
            "\t    T1.CL();",
            "\t    while(m--)in(x),in(y),T1.add(x,y),T1.add(y,x);",
            "\t    T1.get_bridg();",
            "\t    printf(\"%d\\n\",ans);",
            "    }",
            "}",
            ""
        ],
        "description": "插入 割边,桥"
    }
}