#C8814. Palindrome Conversion by Replacement
Palindrome Conversion by Replacement
Palindrome Conversion by Replacement
You are given a string (s) and an integer (k). Your task is to determine if it is possible to convert (s) into a palindrome by replacing at most (k) characters. A palindrome is a string that reads the same forwards and backwards. In order to decide whether conversion is possible, compare the characters at symmetric positions from the beginning and the end of the string. Let the number of mismatched pairs be (m). If (m \leq k), then it is possible to convert the string into a palindrome; otherwise, it is not.
You need to process multiple test cases. The input begins with an integer (T) representing the number of test cases, followed by (T) lines each containing a string and an integer (separated by a space). For each test case, output a single line containing either "Yes" or "No".
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer (T) ((1 \leq T \leq 10^5)), representing the number of test cases.
- Each of the next (T) lines contains a string (s) and an integer (k) ((0 \leq k \leq |s|/2)) separated by a space.
outputFormat
For each test case, output one line from stdout containing "Yes" if it is possible to convert the string into a palindrome by replacing at most (k) characters; otherwise, output "No".## sample
3
abca 1
racecar 1
abcdef 2
Yes
Yes
No
</p>