//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-2.6时间分治",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#include<stack>",
            "#include<map>",
            "#define LL long long",
            "#define Re register int",
            "#define mp make_pair",
            "using namespace std;",
            "const int N=1e5+3,M=2e5+3;",
            "int x,y,l,r,n,m,T,Ans[N];char ch[20];",
            "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 Union{// 冰茶姬（并查集）",
            "\tstruct BK{int x,y,sizex,sizey;BK(Re X=0,Re S1=0,Re Y=0,Re S2=0){x=X,y=Y,sizex=S1,sizey=S2;}};",
            "\tint fa[N<<1],size[N<<1];stack<BK>Q;",
            "\tinline int find(Re x){return fa[x]==x?x:find(fa[x]);}",
            "\tinline void merge(Re x,Re y){// 启发式合并",
            "\t\tx=find(x),y=find(y);",
            "\t\tif(x==y)return;",
            "\t\tif(size[x]>size[y])swap(x,y);",
            "\t\tQ.push(BK(x,size[x],y,size[y]));",
            "\t\tfa[x]=y,size[y]+=size[x];",
            "\t}",
            "\tinline void back(Re to){// 撤销操作",
            "\t\twhile(int(Q.size())>to){",
            "\t\t\tBK a=Q.top();Q.pop();",
            "\t\t\tfa[a.x]=a.x,size[a.x]=a.sizex;",
            "\t\t\tfa[a.y]=a.y,size[a.y]=a.sizey;",
            "\t\t}",
            "\t}",
            "}TF;",
            "int o,head[N<<2];",
            "struct QAQ{int x,y,next;}a[M*20];",
            "inline void add(Re x,Re y1,Re y2){a[++o].x=y1,a[o].y=y2,a[o].next=head[x],head[x]=o;}",
            "struct Segment_Tree{",
            "\t#define pl (p<<1)",
            "\t#define pr (p<<1|1)",
            "\t#define mid ((L+R)>>1)",
            "\tinline void change(Re p,Re L,Re R,Re l,Re r,Re x,Re y){",
            "\t\tif(l>r)return;",
            "\t\tif(l<=L&&R<=r){add(p,x,y);return;}",
            "\t\tif(l<=mid)change(pl,L,mid,l,r,x,y);",
            "\t\tif(r>mid)change(pr,mid+1,R,l,r,x,y);",
            "\t}",
            "\tinline void dfs(Re p,Re L,Re R){",
            "\t\tRe tmp=TF.Q.size();",
            "\t\tfor(Re i=head[p];i;i=a[i].next){",
            "\t\t\tif(TF.find(a[i].x)==TF.find(a[i].y)){",
            "\t\t\t\tfor(Re j=L;j<=R;++j)Ans[j]=1;",
            "\t\t\t\tTF.back(tmp);return;",
            "\t\t\t}",
            "\t\t\tTF.merge(a[i].x,a[i].y+n),TF.merge(a[i].x+n,a[i].y);",
            "\t\t}",
            "\t\tif(L<R)dfs(pl,L,mid),dfs(pr,mid+1,R);",
            "\t\tTF.back(tmp);",
            "\t}",
            "}T1;",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(n),in(m),in(T);",
            "\tfor(Re i=1;i<=(n<<1);++i)TF.fa[i]=i,TF.size[i]=1;",
            "\tfor(Re i=1;i<=m;++i)in(x),in(y),in(l),in(r),T1.change(1,1,T,l+1,r+1-1,x,y);",
            "\tT1.dfs(1,1,T);",
            "\tfor(Re i=1;i<=T;++i)puts(Ans[i]?\"No\":\"Yes\");",
            "}",
            ""
        ],
        "description": "插入 线段树分治 (冰茶姬 判断二分图)"
    }
}