1748: PalindromeFactory

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

A palindrome is a string that reads the same forward and backward. Not all strings are palindromes and we are going to fix that. In this problem we consider four edit operations: 1.Insert a character at any position of a string (including the beginning and the end) 2.Delete a character at any position of a string 3.Change a character at any position of a string 4.Swap any two different characters (not necessarily adjacent) You can apply the first three operations any number of times, but the last operation can be applied at most once. You are given a string initial. Return the minimal number of operations needed to make a palindrome from it.

输入

Each line a initial string

输出

Each line a number means the minimal number of operations.

样例输入 复制

abba
babacvabba
abc

样例输出 复制

0
2
1

来源/分类