-->
当前位置:首页 > 题库

PROGRAMMING:The price of perfection

Luz5年前 (2021-05-10)题库401
Palindrome string is a special kind of string. It is the same to read from left to right and from right to left. Some people think palindrome string is a perfect string. Now give you a string, it is not necessarily palindrome, please calculate the minimum number of exchanges to make the string into a palindrome string. The interchange here refers to the interchange of two adjacent characters in a string.
For example, the given string is "mamad". For the first time, exchange a and D to get "mamda". For the second time, exchange M and D to get "madma"; The last m and a are exchanged for the third time to get "madam".
###Input format:
The first line is an integer n (n < = 80), which indicates the length of the given string. The second line is the given string, which is n in length and contains only lowercase English letters.
###Output format:
If the given string can be changed into palindrome string after several times of exchange, the minimum number of exchanges required will be output; Otherwise, output impossible.
###Input example:
```in
five
mamad
```
###Output example:
```out
three
```







answer:If there is no answer, please comment