#P5550. Swap and Shift Operations

    ID: 18780 Type: Default 1000ms 256MiB

Swap and Shift Operations

Swap and Shift Operations

Chino is given an array \(a_1, a_2, \ldots, a_n\) of \(n\) numbers and two integers \(s\) and \(m\). She is also given an integer \(k\) representing the number of operations to perform.

Each operation consists of the following two steps:

  1. Swap the elements at positions \(s\) and \(m\): \(\operatorname{swap}(a_s,a_m)\).
  2. Rotate the entire array one position to the left (i.e. move the first element to the end of the array).

After performing \(k\) such operations, output the final state of the array.

inputFormat

The first line contains four space-separated integers: \(n\), \(k\), \(s\), and \(m\).

The second line contains \(n\) space-separated integers representing the array \(a_1, a_2, \ldots, a_n\).

outputFormat

Output the final configuration of the array after performing \(k\) operations. The numbers should be printed in a single line separated by spaces.

sample

5 1 2 4
1 2 3 4 5
4 3 2 5 1