luogu#P5217. 贫穷
贫穷
Background
LHF’s biggest trait is being poor.
LHF’s biggest hobby is watching shopping TV shows.
Today, he was watching a shopping show again.
On the show, he saw a new type of text editor. It was very suitable for a poor person like him except for the price.
Because… it can calculate printing costs.
(The printing cost here depends on the number of different kinds of letters that have appeared.)
He was very interested and asks you to implement this feature.
Problem Description
This text editor supports the following operations:
- : Insert a after the -th letter.
- : Delete the -th letter.
- : Reverse the interval in the current text.
- : Output the position of the -th letter in the initial text within the current text. In particular, if it does not exist, output .
- : Output the -th letter in the current text.
- : Output the number of different kinds of letters that have appeared in interval of the current text.
Input Format
The first line contains two integers , representing the length of the initial text and the number of operations.
The second line contains a string of length , representing the initial text.
The next lines each describe one operation.
Output Format
For every operation that requires output, print the result.
12 6
kimiwakawaii
R 2 4
P 4
D 1
I 0 w
T 3
Q 3 10
2
m
5
Hint
Constraints:
For of the testdata, .
For of the testdata, .
For of the testdata, , and the text contains only lowercase letters.
Sample Explanation:
- The text does not change, but the positions of the -nd and -th letters in the initial text are swapped.
- The current -nd letter is the -th letter of the initial text.
- The text becomes .
- The text becomes .
- This letter is .
- This segment is , and the set of character kinds it contains is $\{\texttt{a},\texttt{i},\texttt{k},\texttt{m},\texttt{w}\}$, so the number of elements is .
Translated by ChatGPT 5