#P5787. 【模板】线段树分治 / 二分图

【模板】线段树分治 / 二分图

Description

Shenben has a graph with nn nodes.

Because Shenben is Shenben, within time kk, there will be mm edges that appear and then disappear.

Shenben asks you to determine whether the graph is a bipartite graph in each time period.

Such an easy problem is of course no problem for Shenben, so he wants to test you.

Originally BZOJ4025.

Input Format

The first line contains three integers n,m,kn,m,k.

In the next mm lines, each line contains four integers x,y,l,rx,y,l,r, meaning there is an edge connecting x,yx,y that appears at time ll and disappears at time rr.

Output Format

Output kk lines. The ii-th line contains a string Yes or No, indicating whether the graph is bipartite in the ii-th time period.

3 3 3
1 2 0 2
2 3 0 3
1 3 1 2

Yes
No
Yes

Hint

Sample Explanation

At time 00, two edges (1,2)(1,2) and (2,3)(2,3) appear.

In the 11st time period, this graph is bipartite, so output Yes.

At time 11, an edge (1,3)(1,3) appears.

In the 22nd time period, this graph is not bipartite, so output No.

At time 22, the two edges (1,2)(1,2) and (1,3)(1,3) disappear.

In the 33rd time period, there is only one edge (2,3)(2,3), and this graph is bipartite, so output Yes.

Constraints

n,k=105n,k = 10^5, m=2×105m = 2\times 10^5. 1x,yn1 \le x,y \le n, 0lrk0 \le l \le r \le k.

Notes

This problem has hack testdata (Subtask 22), worth 00 points, but if you do not pass the hack testdata, it will not be considered accepted.

Translated by ChatGPT 5