No.3774 Minimum Cost For Palindrome
Problem Statement
You are given a string $S$ consisting only of lowercase English letters. Find the minimum non-negative integer $C$ satisfying the following condition.
- $S$ can be made into a palindrome by replacing exactly $C$ characters of $S$, each with any lowercase English letter of your choice.
It can be proved that, under the constraints of this problem, a non-negative integer $C$ satisfying the condition exists.
Input
$S$
The input satisfies the following constraints.
- $1 \le |S| \le 10^6$, where $|S|$ is the length of $S$
- $S$ is a string consisting only of lowercase English letters
Output
Print the minimum value of $C$ satisfying the condition.
Make sure to print a newline at the end of the output.
Sample
Sample 1
Input
waiwaiac
Output
2
By replacing the $5$-th and $8$-th characters of $S$ with w and w respectively, $S$ becomes waiwwiaw, which is a palindrome.
Since $S$ cannot be made into a palindrome by changing $1$ or fewer characters, the answer is $2$.
Sample 2
Input
aba
Output
0
Note the case where $S$ is already a palindrome.
Sample 3
Input
yukicoder
Output
4
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
UT0911