#P5041. [HAOI2009] 求回文串
[HAOI2009] 求回文串
Description
A palindrome is a string that reads the same forwards and backwards. For example, ABCBA is a palindrome, while ABCAB is not. Given any input string, you may repeatedly swap the -th character with the -th character to eventually make the string a palindrome. Find the minimum number of swaps.
Input Format
A string consisting of uppercase letters.
Output Format
If it can be transformed into a palindrome by a finite number of operations, output the minimum number of operations; otherwise output .
SHLLZSHZS
4
Hint
Sample Explanation:
- Swap and to get .
- Swap and to get .
- Swap and to get .
- Swap and to get .
Constraints:
- For of the testdata, length .
- For of the testdata, length .
Translated by ChatGPT 5
京公网安备 11011102002149号