P28888 [洛谷] Mine Shaft: Collapse
提高
题目描述

Problem Background

  • Made By tomoo

Why is CYJian's family so wealthy? Because they own a mine!

Despite having a mine, CYJian's family cannot be reckless. Unfortunately, their mine has collapsed...

change: The problem setter has kindly increased the space limit

Problem Description

After the collapse of CYJian's mine, they lost their source of income (do not ask why they have no savings).

CYJian is eager to repair his family's mine.

The mine produces three types of ores: $A, B, C$. Therefore, we can only use materials $A, B, C$ to repair it. We know there are $N$ tons of materials, each being one of the three types, arranged in a sequence, such as:
$$ABCBCABCBACBCBAA$$
CYJian's family has strict requirements for materials. They will choose a continuous interval of materials for repair. These materials must meet the following two requirements:
- The continuous interval must be of the same type of material.
- The material before and after this interval must be different.

For example, given a sequence of materials $AACBBABBBCCCBBB$, the interval $(4$~$5)$ $BB$ and $(5$~$5)$ $B$ both meet the requirements, while the interval $(10$~$12)$ $CCC$ does not.

The materials are magical and can change.

There are $N$ tons of materials and $K$ queries. Each query is one of the following two types:

  • A x y op indicates a material replacement, where the materials from $x$ to $y (1<=x<=y<=N)$ are replaced with $op$, which is one of the characters $A, B, C$.
  • B x y indicates a validity check, where it checks if the materials from $x$ to $y (1<=x<=y<=N)$ are valid. If valid, output $Yes$; if not, output $No$.

Note: When $x=1$ or $y=N$, your program does not need to check the materials before or after the interval, only the interval itself.

Input Format

  • The first line contains a positive integer $N$.
  • The next line contains $N$ characters representing the materials.
  • The next $K$ lines contain the queries, formatted as described above.

Output Format

For each B x y query, output $Yes$ or $No$.

Sample Input and Output

Input Sample #1

15
AACBBABBBCCCBBB
3
B 4 5
B 5 5
B 10 12

Output Sample #1

Yes
Yes
No

Input Sample #2

5
ABBBB
2
B 1 4
B 2 5

Output Sample #2

No
Yes

Notes

  • For $30\%$ of the data, $N \le 1000, K \le 2000$.
  • For $70\%$ of the data, $N \le 5000, K \le 5000$.
  • For $100\%$ of the data, $N \le 500000, K \le 500000, 1 < x <= y < N$.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
15 AACBBABBBCCCBBB 3 B 4 5 B 5 5 B 10 12
样例输出
Yes Yes No