問題一覧 > 通常問題

No.3774 Minimum Cost For Palindrome

レベル : / AI推定難易度 : 130 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 73
作問者 : Rapca1256 / テスター : UT0911 aogera 👑 p-adic tomorunn
お気に入りにしたユーザー ProblemId : 13756 / 自分の提出
問題文最終更新日: 2026-09-06 19:57:33
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 519 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。