#P16837. [GKS 2021 #A] K-Goodness String

[GKS 2021 #A] K-Goodness String

Problem Description

Charles defines the goodness score of a string as the number of indices ii such that SiSNi+1S_i \ne S_{N-i+1} where 1iN/21 \le i \le N/2 (11-indexed). For example, the string CABABC has a goodness score of 22 since S2S5S_2 \ne S_5 and S3S4S_3 \ne S_4.

Charles gave Ada a string SS of length NN, consisting of uppercase letters and asked her to convert it into a string with a goodness score of KK. In one operation, Ada can change any character in the string to any uppercase letter. Could you help Ada find the minimum number of operations required to transform the given string into a string with goodness score equal to KK?

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow.

The first line of each test case contains two integers NN and KK. The second line of each test case contains a string SS of length NN, consisting of uppercase letters.

Output Format

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 11) and yy is the minimum number of operations required to transform the given string SS into a string with goodness score equal to KK.

2
5 1
ABCAA
4 2
ABAA
Case #1: 0
Case #2: 1

Hint

In Sample Case #11, the given string already has a goodness score of 11. Therefore the minimum number of operations required is 00.

In Sample Case #22, one option is to change the character at index 11 to B in order to have a goodness score of 22. Therefore, the minimum number of operations required is 11.

Limits

1T1001 \le T \le 100.

0KN/20 \le K \le N/2.

Test Set 11

1N1001 \le N \le 100.

Test Set 22

1N2×1051 \le N \le 2 \times 10^5 for at most 1010 test cases.

For the remaining cases, 1N1001 \le N \le 100.