(CodeForces - 600C)Make Palindrome

该博客介绍了CodeForces的一道编程题,要求通过最小次数改变字符串中的字符来构造回文串。内容涉及如何确定字符更改策略,确保构造的回文串字典序最小。举例说明了输入输出格式,并提供了问题的解决思路,包括考虑字符个数为偶数和奇数的情况,以及使用贪心策略和模拟来解决问题。
摘要由CSDN通过智能技术生成

(CodeForces - 600C)Make Palindrome

time limit per test:2 seconds
memory limit per test:256 megabytes
input:standard input
output:standard output

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.

Input

The only line contains string s (1 ≤ |s| ≤ 2·

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值