What's more fun than building snowmen? Building snow walls! A snow wall is a simple yet elegant structure, constructed with the most refreshing element of pure white blocks of snow. Snow walls are not too difficult to make, and are extremely rewarding as the length of the wall grows!
On this fine day, there are many people working on «The Great Snow Wall», a gigantic snow wall that will be made of blocks of snow all in a line on 's lawn. Sometimes throughout the day, hears the indefatigable project overseer shouting outside. Each time is shouting, he is either ordering for all the blocks between position and position (inclusive) to be constructed, or deconstructed because it's not up to quality. The height of the wall will always be at most one, so workers only need to construct blocks that are not already up. Each time calls for a part of the wall to be constructed/deconstructed, his trusty workers finish the work instantaneously.
«The Great Snow Wall» never gets completed, so he wants to know how many blocks of snow are in the longest completed section of the wall whenever yells. Sometimes, this number is too disconcerting, in which case will call his wall dismantling drone to destroy the longest completed section of the wall (he may do this multiple times in succession). If there is a tie, the drone will only destroy the section closest to the left. Can you help to keep track of the giant wall on his lawn?would like to ensure that
Subtask 1 [20%]
Subtask 2 [80%]
The first line of input will contain two integers, and .
The next lines will each contain the following:
The first integer of each line will be .
- If , a deconstruction has been made. The next two integers will be and , the range which has been deconstructed.
- If , a construction has been made. The next two integers will be and , the range which has been constructed.
- If , puts his dismantling drone to action.
After each construction/deconstruction, output one integer, the span of the maximum contiguous completed section of the wall.
10 5 1 1 10 0 4 6 0 4 7 2 1 4 10
10 4 3 7
Explanation for Sample Output
Let's outline what happened (
0 will represent unbuilt blocks,
1 will represent built):
In the first update, the entire wall is built.
In the second update, feels the wall is … off, so he orders blocks 4 to 6 to be destroyed.
In the third update, blocks 4 to 7 are ordered to be destroyed, but 4 to 6 are already missing, so just block 7 gets taken down.
A drone dismantling is then in place. Since there is a tie, the drone takes down the first three blocks.
Finally, orders every block from 4 to 10 to be put up.