#P6448. [COCI 2008/2009 #4] MJEHURIC
[COCI 2008/2009 #4] MJEHURIC
Description
Given a sequence consisting of five numbers, each of appears exactly once among these five numbers. Now sort the sequence using the following operations.
- If , swap and .
- If , swap and .
- If , swap and .
- If , swap and .
- If the sequence has not become , go back to step 1 and continue sorting.
Output the current sequence after each swap.
Input Format
The input contains only one line with five numbers, representing the sequence .
Output Format
Output several lines. Each line contains five integers separated by spaces, representing the sequence after one swap.
2 1 5 3 4
1 2 5 3 4
1 2 3 5 4
1 2 3 4 5
2 3 4 5 1
2 3 4 1 5
2 3 1 4 5
2 1 3 4 5
1 2 3 4 5
Hint
Constraints
For all test points, it is guaranteed that , all are distinct, and the sequence is not strictly increasing.
Hint
It can be proven that the number of swaps does not exceed .
This problem is translated from COCI2008-2009 CONTEST #4 T1 MJEHURIC.
Translated by ChatGPT 5
京公网安备 11011102002149号