luogu#P4979. 矿洞:坍塌
矿洞:坍塌
Background
- Made By tomoo
Why is CYJian’s family so rich? Because his family&@%# runs a mine!!
Even if you have a mine, you cannot be reckless. Well, CYJian’s mine collapsed......
change: The setter kindly increased the memory limit.
Problem Description
After CYJian’s mine collapsed, he no longer has any source of income (do not ask me why he has no savings).
So CYJian urgently wants to repair his mine.
CYJian’s mine produces three kinds of ores: . Therefore, we can only use the three kinds of materials to repair the mine. We know there are a total of tons of materials. Each ton is one of , and they are connected into a string, for example:
CYJian has very strict requirements for the materials. Each time, he will choose a continuous interval of materials as the repair materials. Because unqualified materials may cause the mine to collapse again and kill CYJian, this continuous interval must satisfy the following requirements:
- This continuous interval must consist of only one kind of material.
- The material immediately before this interval and the material immediately after this interval must be different.
For example, given a segment , the interval which is and the interval which is both satisfy the requirements, but the interval which is does not.
The materials are “alive”, so they can change.
Now there are tons of materials and queries. Each query is one of the following two types:
A x y opmeans a replacement operation: replace the materials in the interval from to with , where is one of the characters .B x ymeans a check query: ask whether the materials in the interval from to are valid. OutputYesif valid, otherwise outputNo.
Note: When or , your program does not need to check the outside neighbors, and only needs to check the interval itself.
Input Format
- The first line contains a positive integer .
- The next line contains characters, representing the materials.
- Then follow queries, each in one of the formats above.
Output Format
For each query B x y, output one line Yes or No.
15
AACBBABBBCCCBBB
3
B 4 5
B 5 5
B 10 12
Yes
Yes
No
5
ABBBB
2
B 1 4
B 2 5
No
Yes
Hint
- For of the testdata, .
- For of the testdata, .
- For of the testdata, $N\le5\cdot10^5,K\le5\cdot10^5, 1\leq x \leq y \leq N$.
Translated by ChatGPT 5