//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.4染色法",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define Re register int",
            "using namespace std;",
            "const int N=2003,M=1e6+3;",
            "int n,m,x,y,h,t,o,T,O,Q[N],head[N],color[N];",
            "struct QAQ{int to,next;}a[M<<1];",
            "inline void add(Re x,Re y){a[++o].to=y,a[o].next=head[x],head[x]=o;}",
            "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 judge(){",
            "\tfor(Re i=1;i<=n;++i)",
            "\t\tif(!color[i]){",
            "\t\t\th=1,t=0,Q[++t]=i,color[i]=1;",
            "\t\t\twhile(h<=t){",
            "\t\t\t\tRe x=Q[h++];",
            "\t\t\t\tfor(Re j=head[x],to;j;j=a[j].next)",
            "\t\t\t\t\tif(!color[to=a[j].to])color[to]=3-color[x],Q[++t]=to;",
            "\t\t\t\t\telse if(color[to]==color[x])return 0;",
            "\t\t\t}",
            "\t\t}",
            "\treturn 1;",
            "}",
            "int main(){",
            "\tin(T);",
            "\twhile(T--){",
            "\t\tmemset(color,0,sizeof(color));",
            "\t\tmemset(head,0,sizeof(head));",
            "\t\tin(n),in(m),o=0;",
            "\t\twhile(m--)in(x),in(y),add(x,y),add(y,x);",
            "\t\tprintf(\"Scenario #%d:\\n\",++O);",
            "\t\tputs(judge()?\"No suspicious bugs found!\\n\":\"Suspicious bugs found!\\n\");",
            "\t}",
            "}",
            ""
        ],
        "description": "插入 二分图判定"
    }
}