#P2787. 语文1(chin1)- 理理思维

    ID: 1819 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>搜索线段树洛谷原创枚举,暴力

语文1(chin1)- 理理思维

Description

The exam has started, but HansBug's mind is still blank. Oh no! To be precise, it is a total mess. Your primary task now is to help HansBug organize his thoughts. Assume HansBug's thoughts form a long string (containing only the 2626 letters). Now you have a magic prescription that contains three operations in order:

  1. Get how many times letter kk appears from the xx-th to the yy-th character.
  2. Set all characters from the xx-th to the yy-th to letter kk.
  3. Sort the characters from the xx-th to the yy-th in az\text{a} \sim \text{z} order.

Just when you are overjoyed, his brain cells and RP have already been exhausted by previous nervousness, and there is still an 800800-word essay at the end of the paper. So this crucial task is up to you!

Input Format

The first line contains two integers n,mn, m, denoting the number of letters in HansBug's thoughts and the number of operations on the prescription, respectively. The second line contains a string of length nn, representing HansBug's thoughts.

Then follow mm lines, each describing an operation in the following format (positions are 11-based and inclusive):

  • 1 x y k means to output how many times kk appears from the xx-th to the yy-th character.
  • 2 x y k means to replace all characters from the xx-th to the yy-th with kk.
  • 3 x y means to sort the characters from the xx-th to the yy-th in az\text{a} \sim \text{z} order.

Output Format

Output several lines, each containing an integer, which are the results of all type 1 operations in order.

10 5
ABCDABCDCD
1 1 3 A
3 1 5
1 1 3 A
2 1 2 B
1 2 3 B

1
2
2

Hint

Sample explanation:

Constraints:

This problem is case-insensitive.

Three additional hack testdata groups have been added, which are not in the table above, but it is guaranteed that 1n,m500001 \le n, m \le 50000.

Translated by ChatGPT 5