#P4344. [SHOI2015] 脑洞治疗仪
[SHOI2015] 脑洞治疗仪
Description
The inventor SHTSC, who once created the automatic problem-solving machine, has unveiled his new invention: the Brainhole Treatment Device — a mysterious apparatus that can treat the ever-enlarging “brainholes” caused by his inventions.
For simplicity, we regard the brain as a 01 sequence. means the tissue at that position is working normally, and means it is a brainhole.
1 0 1 0 0 0 1 1 1 0
The basic principle for repairing a certain brainhole is to excavate another contiguous region and use the normal tissue from it to fill the hole. (So is the brainhole treatment device actually a treatment device for brainholes?)
For example, if we use positions to to repair the hole from positions to , we get:
1 1 1 1 0 0 1 0 0 0
If we then use positions to to repair positions to :
0 0 0 0 0 0 1 1 1 1
This is because the Brainhole Treatment Device discards any excess tissue.
If we then use positions to to fill positions to :
1 1 1 1 0 0 0 0 0 0
This is because if the excavated normal tissue is not enough, the device only fills the brainhole as much as possible starting from the earlier positions (smaller indices).
Assume that initially SHTSC has no brainholes. Given a sequence of digging and treatment operations, you need to answer online: within a given interval of the brain, what is the size of the largest contiguous brainhole.
Input Format
The first line contains two integers , meaning SHTSC’s brain is divided into contiguous regions numbered from to , and there are operations.
Each of the following lines is in one of the following three formats:
- : SHTSC digs a brainhole covering the range .
- : SHTSC performs one treatment, using the normal tissue from to to repair the brainholes from to .
- : SHTSC asks for the size of the largest brainhole within the interval .
All the above intervals lie within .
Output Format
For each query, output one line with one integer, the size of the largest contiguous brainhole within the query interval.
10 10
0 2 2
0 4 6
0 10 10
2 1 10
1 8 10 1 4
2 1 10
1 1 4 8 10
2 1 10
1 7 10 1 6
2 1 10
3
3
6
6
Hint
For of the testdata, . For of the testdata, . For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号