#lx002. 智能工厂的回文质检

    ID: 6543 传统题 文件IO:replyqualityinspection 1000ms 256MiB 尝试: 0 已通过: 0 难度: 3.33 上传者: 标签>贪心模拟其他数学deepseek-J-2

智能工厂的回文质检

Title Description

On the quality inspection assembly line of the future factory, the robotic arm is arranging the product sequence. Each product has a letter identifier, and quality inspection requires that the final sequence must be a palindrome. The robotic arm can only exchange the positions of two adjacent products at a time. Please calculate the minimum number of operations required to complete the quality inspection.

Special conditions

When there is a situation where a palindrome cannot be formed (such as multiple letters appearing odd times), the system will automatically sound an alarm

Input format

A string composed of lowercase letters (length 1000\le 1000)

Output format

Minimum number of operations or 1-1

Example

aabb
2