#P10130. 「Daily OI Round 3」War
「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 ships, numbered from to . Each ship has soldiers, numbered from to .
At the beginning, some groups of ships are connected by iron chains. The specific relations are given as follows:
You are given relations, each in the form , meaning that , ship is connected to ship . It is guaranteed that and .
It is guaranteed that , there exists at most one relation such that .
Then there are operations, described as follows (operations are numbered in chronological order):
Operation : Fire a rocket at the soldiers on ship in the interval . After this operation, all soldiers in this interval will be on fire. Due to the chain connections, all soldiers in the interval on every ship that is directly or indirectly connected to will also be on fire. Note that a soldier may catch fire multiple times.
Operation : Revoke the operation numbered , and it is guaranteed that this operation must be operation . 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 : Query whether all soldiers on ship in the interval are on fire. If all are on fire, output Yes, otherwise output No.
Input Format
The first line contains four integers , with meanings as described above.
The next lines each contain four integers, describing a chain relation.
The next lines describe the operations.
The first integer of each line is , indicating the type of operation.
-
If , you need to input three integers , and perform operation as required.
-
If , you need to input one integer , and perform operation as required.
-
If , you need to input three integers , and perform operation as required.
Output Format
Output several lines, each being the answer to an operation .
Friendly reminder: outputting all No or all Yes will get a high score of .
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 and , and , and , and , and are connected. The second one means that ships and , and , and are connected.
In the first operation, a rocket is fired at soldiers to on ship . Since ships to are connected, soldiers to on ships to all catch fire.
In the second operation, it queries whether soldiers to 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 to on the first ship are on fire. Obviously they are not, so output No.
In the fifth operation, soldiers on ship are set on fire. In the sixth operation, soldiers on ship are set on fire. Then in the seventh operation, the sixth operation is revoked. Note: at this moment, soldiers on ships to are on fire.
In the eighth operation, soldiers on ship are set on fire. In the ninth operation, it queries whether are all on fire. Obviously, at this time they are all on fire.
Constraints
For all data, it is guaranteed that: , , , .
Translated by ChatGPT 5