CF600C.Make Palindrome
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s consisting of lowercase Latin letters. At once you can choose any position in the string and change letter in that position to any other lowercase letter. So after each changing the length of the string doesn't change. At first you can change some letters in s. Then you can permute the order of letters as you want. Permutation doesn't count as changes.
You should obtain palindrome with the minimal number of changes. If there are several ways to do that you should get the lexicographically (alphabetically) smallest palindrome. So firstly you should minimize the number of changes and then minimize the palindrome lexicographically.
如果一个字符串从左到右读与从右到左读完全相同,则称其为回文串。例如,"kazak"、"oo"、"r" 和 "mikhailrubinchikkihcniburliahkim" 都是回文串,但字符串 "abb" 和 "ij" 不是。
给定一个由小写拉丁字母组成的字符串 $ s $。每次操作,你可以选择字符串中的任意一个位置,并将该位置上的字符修改为任意其他小写字母。每次修改后,字符串的长度保持不变。首先,你可以对 $ s $ 中的一些字符进行若干次修改;然后,你可以以任意顺序重新排列这些字符(排列本身不计为修改操作)。
你的目标是通过最少次数的修改操作得到一个回文串。如果存在多种方案能达到最少修改次数,则应选择其中字典序(即字母序)最小的回文串。换言之,你应首先最小化修改次数,其次在所有达到该最小修改次数的方案中,最小化所得回文串的字典序。
输入格式
The only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.
唯一一行包含字符串 s(1 ≤ ∣s∣ ≤ 2⋅105),且 s 仅由小写拉丁字母组成。
输出格式
Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes.
输出通过最少修改次数所能得到的字典序最小的回文串。
输入输出样例
输入#1
aabc
输出#1
abba
输入#2
aabcd
输出#2
abcba
输入解题思路,AI测评打分。不知道怎么写?