//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 的格式要求是 "插入 [该代码片段的中文名]"

{
    "欧拉回路  (Hierholzer)": {
        "prefix": "acm-3.3无向+有向",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define Re register int",
            "const int N=1e5+3,M=2e5+3;",
            "int n,m,x,y,m_,op;",
            "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 Euler_Circle__Undirected_Graph{// 无向图欧拉路",
            "\tint o,du[N],cur[N],ans[M],pan[M<<1],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 dfs(Re x){",
            "\t\tfor(Re i=head[x];i;i=head[x]){",
            "\t\t\thead[x]=a[i].next;// 当前弧优化",
            "\t\t\tif(!pan[i]){",
            "\t\t\t\tpan[i]=pan[i^1]=1;",
            "\t\t\t\tdfs(a[i].to);",
            "\t\t\t\tans[++ans[0]]=(i&1)?-i/2:i/2;",
            "\t\t\t}",
            "\t\t}",
            "\t}",
            "\tinline void sakura(){",
            "\t\tin(n),in(m),m_=m,o=1;",
            "\t\twhile(m_--)in(x),in(y),add(x,y),add(y,x),++du[x],++du[y];",
            "\t\tfor(Re i=1;i<=n;cur[i]=head[i],++i)if(du[i]&1){puts(\"NO\");return;}",
            "\t\tfor(Re i=1;i<=n;++i)if(du[i]){dfs(i);break;}",
            "\t\tif(ans[0]!=m){puts(\"NO\");return;}",
            "\t\tputs(\"YES\");",
            "\t\tfor(Re i=ans[0];i>=1;--i)printf(\"%d \",ans[i]);",
            "\t}",
            "}T1;",
            "struct Euler_Circle__Directed_Graph{// 无向图欧拉路",
            "\tint o,ru[N],chu[N],cur[N],ans[M],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 dfs(Re x){",
            "\t\tfor(Re i=head[x];i;i=head[x]){",
            "\t\t\thead[x]=a[i].next;// 当前弧优化",
            "\t\t\tdfs(a[i].to);",
            "\t\t\tans[++ans[0]]=i;",
            "\t\t}",
            "\t}",
            "\tinline void sakura(){",
            "\t\tin(n),in(m),m_=m;",
            "\t\twhile(m_--)in(x),in(y),add(x,y),++ru[y],++chu[x];",
            "\t\tfor(Re i=1;i<=n;cur[i]=head[i],++i)if(ru[i]!=chu[i]){puts(\"NO\");return;}",
            "\t\tfor(Re i=1;i<=n;++i)if(chu[i]){dfs(i);break;}",
            "\t\tif(ans[0]!=m){puts(\"NO\");return;}",
            "\t\tputs(\"YES\");",
            "\t\tfor(Re i=ans[0];i>=1;--i)printf(\"%d \",ans[i]);",
            "\t}",
            "}T2;",
            "int main(){",
            "\tin(op);",
            "\tif(op==1)T1.sakura();",
            "\tif(op==2)T2.sakura();",
            "}",
            ""
        ],
        "description": "插入 欧拉回路  (Hierholzer)"
    }
}