#P12246. 电 van
电 van
Description
You are given a string of length consisting of characters , , and . Let denote the -th character of .
Little O will perform operations. In each operation, you are given an integer (), requiring you to swap and .
After each operation, output the number of times appears as a subsequence in the modified string.
- A string is a subsequence of if it can be obtained by deleting zero or more characters from without changing the order of the remaining characters.
Input Format
The input consists of lines:
- Line : Two integers and , the string length and number of operations.
- Line : A string of length .
- Lines to : Each line contains an integer , representing the -th operation.
Output Format
Output lines, where the -th line contains the answer after the -th operation.
8 3
vvvaannn
4
3
5
18
15
12
Hint
Sample #1 Explanation
Initial State:
- After swapping positions and : remains unchanged. appears 18 times.
- After swapping positions and : . appears 15 times.
- After swapping positions and : . appears 12 times.
Constraints
- ,
Subtask Details
| Test Case | Range | Range | Special Property |
|---|---|---|---|
| None | |||
| A | |||
| None | |||
Special Property A: In all swap operations, at least one of or is .
京公网安备 11011102002149号