//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>",
            "#include<vector>",
            "#define LL long long",
            "#define Re register int",
            "using namespace std;",
            "const int N=1003,M=503;",
            "int n,m,x,y,T,Q_o,tmp,ans1,cut[N];LL ans2;",
            "std::vector<int>dcc[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;",
            "}",
            "inline int max(Re a,Re b){return a>b?a:b;}",
            "struct Tarjan{",
            "\tint o,t,dfn_o,Q[N],dfn[N],low[N],head[N];",
            "\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(head,0,sizeof(head));",
            "\t\tmemset(low,0,sizeof(low));",
            "\t\tmemset(dfn,0,sizeof(dfn));",
            "\t\tmemset(cut,0,sizeof(cut));",
            "\t\tdfn_o=t=o=0;",
            "\t}",
            "\tinline void tarjan(Re x,Re rt){",
            "\t\tRe son=0;Q[++t]=x,dfn[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,rt),++son;",
            "\t\t\t\tlow[x]=min(low[x],low[to]);",
            "\t\t\t\tif(low[to]>=dfn[x]){",
            "\t\t\t\t\tif(x!=rt)cut[x]=1;",
            "\t\t\t\t\telse cut[x]|=son>1;",
            "\t\t\t\t\t++Q_o;",
            "\t\t\t\t\twhile(1){",
            "\t\t\t\t\t\tdcc[Q_o].push_back(Q[t]);",
            "\t\t\t\t\t\tif(to==Q[t--])break;",
            "\t\t\t\t\t}",
            "\t\t\t\t\tdcc[Q_o].push_back(x);",
            "\t\t\t\t}",
            "\t\t\t}",
            "\t\t\telse low[x]=min(low[x],dfn[to]);",
            "\t}",
            "\tinline void SuoPoint(){for(Re i=1;i<=n;++i)if(!dfn[i])tarjan(i,i);}",
            "}T1;",
            "int main(){",
            "    while(scanf(\"%d\",&m)&&m){",
            "\t    for(Re i=1;i<=Q_o;++i)dcc[i].clear();",
            "\t    T1.CL(),Q_o=ans1=n=0,ans2=1;",
            "\t    while(m--)in(x),in(y),T1.add(x,y),T1.add(y,x),n=max(n,max(x,y));",
            "\t    T1.SuoPoint();",
            "\t    for(Re i=1;i<=Q_o;++i){",
            "\t    \ttmp=0,n=dcc[i].size();",
            "\t    \tfor(Re j=0;j<n;++j)tmp+=cut[dcc[i][j]];",
            "\t    \tif(!tmp)ans1+=2,ans2*=(n-1)*n/2;",
            "\t    \telse if(tmp<2)ans1+=1,ans2*=(n-1);",
            "\t    }",
            "\t    printf(\"Case %d: %d %lld\\n\",++T,ans1,ans2);",
            "    }",
            "}",
            ""
        ],
        "description": "插入 缩点—点双连通分量"
    }
}