| Codeforces Round 1123 (Div. 2) |
|---|
| Finished |
A binary string $$$t$$$ of length $$$m$$$ is called clean if $$$t_i = t_{i+1}$$$ for all $$$1\le i\lt m$$$.
The chief engineer of the country has made another discovery. He invented a smart robot that can perform the following operation on any binary string $$$t$$$ for one coin:
Define the beauty of a string $$$t$$$ as the minimum number of coins needed to make it clean. Define the power of a string $$$t$$$ as the sum of the beauties of all its substrings.
You are given a binary string $$$s$$$ of length $$$n$$$. The engineer's competitors are going to modify the string exactly $$$q$$$ times. Each modification is described by one number $$$i$$$. After the modification, $$$s_i$$$ is inverted. Your task is to compute the power of the string $$$s$$$ before and after each modification.
$$$^{\text{∗}}$$$A string $$$a$$$ is a substring of a string $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1\le n, q\le 2\cdot 10^5$$$) — the length of the binary string and the number of modifications.
The second line of each test case contains the binary string $$$s$$$.
The next $$$q$$$ lines of each test case contain one integer $$$i$$$ ($$$1\le i\le n$$$) — the description of the modifications.
It is guaranteed that the sum of all $$$n$$$ values and the sum of all $$$q$$$ values over all test cases do not exceed $$$2\cdot 10^5$$$.
For each test case, output $$$q + 1$$$ integers separated by spaces — the answer before the modifications and after each modification of the string.
43 111024 21010128 410101110352310 51100101110161073
2 27 5 536 23 22 25 2661 66 41 35 59 60
Consider the first test case.
Before the modifications, the string $$$s$$$ is 110. The power of the string is $$$2$$$:
| Name |
|---|


