CF1822E Making Anti-Palindromes

题目描述

给您一个由小写字母组成的字符串 $s$,在每次操作中,您可以交换 $s$ 中的任意两个字母,请问把 $s$ 变为“反回文串”的最小操作次数是多少? “反回文串”定义为:对于一个长度为 $n$ 的字符串 $s$,如果对于任意 $1\leqslant i\leqslant n$ 均有 $s_i\not=s_{n-i+1}$,那么字符串 $s$ 就叫做“反回文串”。

输入格式

输出格式

说明/提示

In the first test case, the string "codeforces" is already an anti-palindrome, so the answer is $ 0 $ . In the second test case, it can be shown that the string "abc" cannot be transformed into an anti-palindrome by performing the allowed operations, so the answer is $ -1 $ . In the third test case, it is enough to swap the second and the fifth characters of the string "taarrrataa", and the new string "trararataa" will be an anti-palindrome, so the answer is $ 1 $ .