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

{
    "2-SAT": {
        "prefix": "acm-3.3tarjan",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define Re register int",
            "const int N=2e6+3,M=2e6+3;",
            "int n,m,p1,p2,x1,x2,Q_o,ip[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;",
            "}",
            "struct Tarjan{",
            "\tint o,t,dfn_o,Q[N],low[N],dfn[N],pan[N],head[N];",
            "\tstruct QAQ{int to,next;}a[M];",
            "\tinline int min(Re a,Re b){return a<b?a:b;}",
            "\tinline void add(Re x,Re y){a[++o].to=y,a[o].next=head[x],head[x]=o;}",
            "\tinline void tarjan(Re x){",
            "\t\tlow[x]=dfn[x]=++dfn_o,Q[++t]=x,pan[x]=1;",
            "\t\tfor(Re i=head[x],to;i;i=a[i].next)",
            "\t\t\tif(!dfn[to=a[i].to])tarjan(to),low[x]=min(low[x],low[to]);",
            "\t\t\telse if(pan[to])low[x]=min(low[x],dfn[to]);",
            "\t\tif(low[x]==dfn[x]){",
            "\t\t\t++Q_o;",
            "\t\t\twhile(1){",
            "\t\t\t\tip[Q[t]]=Q_o,pan[Q[t]]=0;",
            "\t\t\t\tif(x==Q[t--])break;",
            "\t\t\t}",
            "\t\t}",
            "\t}",
            "\tinline void SuoPoint(){for(Re i=1;i<=2*n;++i)if(!dfn[i])tarjan(i);}",
            "}T1;",
            "int main(){",
            "\tin(n),in(m);",
            "\twhile(m--)in(p1),in(x1),in(p2),in(x2),T1.add(p1+(x1^1)*n,p2+x2*n),T1.add(p2+(x2^1)*n,p1+x1*n);",
            "\tT1.SuoPoint();",
            "\tfor(Re i=1;i<=n;++i)if(ip[i]==ip[i+n])return !printf(\"IMPOSSIBLE\");",
            "\tputs(\"POSSIBLE\");",
            "\tfor(Re i=1;i<=n;++i)printf(\"%d \",ip[i]>ip[i+n]);",
            "}"
        ],
        "description": "插入 2-SAT"
    }
}