Explanation of Output for Sample
By swapping the S and M, we end up with LLMLS. Then the M can be swapped with the L to its right. This is one way to use two swaps to arrange the books as Valentina wants them to be. It is not possible to use fewer swaps because both S and M need to be moved but usingone swap to exchange them does not leave the books arranged as Valentina wants them tobe.
输出解释
通过交换S和M,我们得到LLMLS。然后可以将M与其右侧的L交换。这是一种用两次交换来安排书籍的方法,使之符合瓦伦蒂娜的意愿。由于S和M都需要移动,但使用一次交换来交换它们并不能使书籍按瓦伦蒂娜希望的方式排列,因此不可能用更少的交换次数完成。