#abc157e. E - Simple String Queries
E - Simple String Queries
Score : points
问题描述
你将得到一个长度为 的由小写英文字母组成的字符串 。
处理 个查询,查询有两种类型:
- 类型 1:将 中的第 个字符更改为 。(如果第 个字符已经是 ,则无需执行任何操作。)
- 类型 2:计算并回答在从第 个到第 个(包括两端)字符之间的子串中出现的不同字符数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string of length consisting of lowercase English letters.
Process queries of the following two types:
- Type : change the -th character of to . (Do nothing if the -th character is already .)
- Type : answer the number of different characters occurring in the substring of between the -th and -th characters (inclusive).
Constraints
- , , , , and are integers.
- is a string consisting of lowercase English letters.
- is a lowercase English letter.
- There is at least one query of type in each testcase.
Input
Input is given from Standard Input in the following format:
Here, in the -th through -th lines is one of the following:
Output
For each query of type , print a line containing the answer.
Sample Input 1
7
abcdbbd
6
2 3 6
1 5 z
2 1 1
1 4 a
1 7 d
2 1 7
Sample Output 1
3
1
5
In the first query, cdbb
contains three kinds of letters: b
, c
, and d
, so we print .
In the second query, is modified to abcdzbd
.
In the third query, a
contains one kind of letter: a
, so we print .
In the fourth query, is modified to abcazbd
.
In the fifth query, does not change and is still abcazbd
.
In the sixth query, abcazbd
contains five kinds of letters: a
, b
, c
, d
, and z
, so we print .
update @ 2024/3/10 17:15:00