#ABC476E. 最值交换 / Min-Max Swap
最值交换 / Min-Max Swap
Problem Statement
You are given a permutation of and length- integer sequences and .
For this permutation , perform the following operation for in this order:
- Among , swap the positions of the element with the minimum value and the element with the maximum value.
Find each element of after the operations.
Constraints
- is a permutation of .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output each element of after the operations, in order from front to back, separated by spaces.
5 3
3 1 4 2 5
1 3
1 5
1 4
3 4 2 5 1
Initially, .
- For : among , the minimum value is and the maximum value is . Swapping and gives .
- For : among , the minimum value is and the maximum value is . Swapping and gives .
- For : among , the minimum value is and the maximum value is . Swapping and gives .
After the three operations, .
6 7
3 6 5 2 4 1
4 5
2 3
3 5
4 6
3 4
1 6
3 5
3 5 4 6 2 1
- Source: AtCoder ABC 476 E
相关
在下列比赛中: