QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#3437. 重排回文

Statistiques

Per 最近刚了解到回文(palindrome)。现在他想告诉我们这件事,并分享更多很棒的科学新闻。

“回文是一个无论从后往前读还是从前往后读都一样的单词,”Per 最近在一次采访中说道。他继续说:“例如,add 不是回文,因为把它倒过来读是 dda,这显然不是同一个词。然而,如果我们重新排列这个词的字母,我们实际上可以得到一个回文。因此,我们称 add 为一个 Peragram,因为它是一个回文的变位词(anagram)。”

Per 给出了 Peragram 更正式的定义:“就像我说的,如果一个单词至少是一个回文的变位词,我们就称它为 Peragram。回想一下,单词 $w$ 的变位词包含与 $w$ 完全相同的字母,只是顺序可能不同。”

照片由 Ross Beresford 提供

任务

给定一个字符串,求出为了使该字符串成为一个 Peragram,最少需要删除的字母数量。

输入格式

输入包含一行字符串。字符串长度至少为 1,至多为 1000。字符串仅包含小写字母 a-z。

输出格式

输出应包含一个整数,即为了使字符串成为 Peragram 而必须删除的最少字符数。

样例

输入格式 1

abc

输出格式 1

2

输入格式 2

aab

输出格式 2

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.