#P10130. 「Daily OI Round 3」War

    ID: 10975 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>线段树树状数组洛谷原创O2优化

「Daily OI Round 3」War

Background

"Battle of Red Cliffs" is an open-world adventure game. This means that from the very first moment you step into Teyvat, as long as you plan your stamina well, whether you climb over mountains or cross rivers, there is always a way to see new scenery.

Problem Description

There are nn ships, numbered from 11 to nn. Each ship has mm soldiers, numbered from 11 to mm.

At the beginning, some groups of ships are connected by iron chains. The specific relations are given as follows:

You are given ss relations, each in the form l1,r1,l2,r2l_1,r_1,l_2,r_2, meaning that k[0,r1l1]\forall k \in [0,r_1-l_1], ship l1+kl_1+k is connected to ship l2+kl_2+k. It is guaranteed that r1l1+1=r2l2+1r_1-l_1+1=r_2-l_2+1 and l1<l2l_1 < l_2.

It is guaranteed that p[1,n]\forall p \in [1,n], there exists at most one relation such that l2pr2l_2 \le p \le r_2.

Then there are qq operations, described as follows (operations are numbered 1q1 \sim q in chronological order):

Operation 11: Fire a rocket at the soldiers on ship pp in the interval [L,R][L,R]. After this operation, all soldiers in this interval will be on fire. Due to the chain connections, all soldiers in the interval [L,R][L,R] on every ship that is directly or indirectly connected to pp will also be on fire. Note that a soldier may catch fire multiple times.

Operation 22: Revoke the operation numbered pp, and it is guaranteed that this operation must be operation 11. It is guaranteed that the same operation will not be revoked more than once, and all future queries will not consider the effects caused by revoked operations.

Operation 33: Query whether all soldiers on ship pp in the interval [L,R][L,R] are on fire. If all are on fire, output Yes, otherwise output No.

Input Format

The first line contains four integers n,m,s,qn,m,s,q, with meanings as described above.

The next ss lines each contain four integers, describing a chain relation.

The next qq lines describe the operations.

The first integer of each line is opop, indicating the type of operation.

  • If op=1op=1, you need to input three integers p,L,Rp,L,R, and perform operation 11 as required.

  • If op=2op=2, you need to input one integer pp, and perform operation 22 as required.

  • If op=3op=3, you need to input three integers p,L,Rp,L,R, and perform operation 33 as required.

Output Format

Output several lines, each being the answer to an operation 33.

Friendly reminder: outputting all No or all Yes will get a high score of 0 pts0\text{ pts}.

10 20 2 9
1 5 2 6
7 9 8 10
1 4 1 5
3 6 2 3
2 1
3 6 2 3
1 10 2 7
1 9 3 6
2 6
1 7 8 13
3 8 2 12
Yes
No
Yes
10 10 2 10
1 1 2 2
1 1 8 8
1 2 1 8
1 6 7 8
1 8 7 8
1 9 6 7
3 8 3 3
2 4
1 5 7 8
3 3 3 3
3 6 3 3
2 3
Yes
No
No

Hint

Sample Explanation #1

First, two relations are given. The first one means that ships 11 and 22, 22 and 33, 33 and 44, 44 and 55, 55 and 66 are connected. The second one means that ships 77 and 88, 88 and 99, 99 and 1010 are connected.

In the first operation, a rocket is fired at soldiers 11 to 55 on ship 44. Since ships 11 to 66 are connected, soldiers 11 to 55 on ships 11 to 66 all catch fire.

In the second operation, it queries whether soldiers 22 to 33 on the first ship are on fire. Obviously they are, so output Yes.

In the third operation, the first operation is revoked, so after that, no soldiers are on fire.

In the fourth operation, it queries whether soldiers 22 to 33 on the first ship are on fire. Obviously they are not, so output No.

In the fifth operation, soldiers [2,7][2,7] on ship 1010 are set on fire. In the sixth operation, soldiers [3,6][3,6] on ship 99 are set on fire. Then in the seventh operation, the sixth operation is revoked. Note: at this moment, soldiers [2,7][2,7] on ships 77 to 1010 are on fire.

In the eighth operation, soldiers [8,13][8,13] on ship 77 are set on fire. In the ninth operation, it queries whether [2,12][2,12] are all on fire. Obviously, at this time they are all on fire.

Constraints

For all data, it is guaranteed that: 1n1091 \le n\leq 10^9, 1m5×1051 \le m\leq 5\times 10^5, 0q1050 \le q\leq 10^5, 0s2000 \le s\leq 200.

Translated by ChatGPT 5