//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.4add",
        "body": [
            "#include<cstring>",
            "#include<cstdio>",
            "#define Re register int",
            "const int N=1003;",
            "int o,n,m,e,x,y,ans,pan[N],head[N],match[N];",
            "struct QAQ{int to,next;}a[N*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 void add(Re x,Re y){a[++o].to=y,a[o].next=head[x],head[x]=o;}",
            "inline int dfs(Re x){",
            "\tfor(Re i=head[x],to;i;i=a[i].next)",
            "\t\tif(!pan[to=a[i].to]){",
            "\t\t\tpan[to]=1;",
            "\t\t\tif(!match[to]||dfs(match[to])){",
            "\t\t\t\tmatch[to]=x;return 1;",
            "\t\t\t}",
            "\t\t}",
            "\treturn 0;",
            "}",
            "int main(){",
            "\tin(n),in(m),in(e);",
            "\twhile(e--){",
            "\t\tin(x),in(y);",
            "\t\tif(x<=n&&y<=m)add(x,y);",
            "\t}",
            "\tfor(Re i=1;i<=n;++i){",
            "\t\tmemset(pan,0,sizeof(pan));",
            "\t\tans+=dfs(i);",
            "\t}",
            "\tprintf(\"%d\",ans);",
            "}",
            ""
        ],
        "description": "插入 二分图—最大匹配"
    }
}