#P6823. 「EZEC-4」paulzrm Loves Array
「EZEC-4」paulzrm Loves Array
Background
Original statement:
has an array consisting of integers: . The initial value of is . There are operations, including four types as follows.
Type : 1 sort the array.
Type : 2 sort the array and reverse it.
Type : 3 x y swap . It is guaranteed that is not equal to , and .
Type : 4 reverse the array.
You need to output the array after operations.
First line with two intergers .
Next lines are the operations.
One line, numbers, the array.
Problem Description
Xiao Z has a sequence of length with indices starting from . Initially, the number at position is . There are operations, and each operation is one of the following four types.
1Sort the sequence in increasing order.2Sort the sequence in increasing order and then reverse it (i.e., sort in decreasing order).3 x ySwap the numbers at indices and . It is guaranteed that and .4Reverse the sequence.
You need to output the sequence after operations.
Input Format
The first line contains two integers , representing the length of the sequence and the number of operations.
The next lines each contain one operation. It is guaranteed that all operations are valid.
Output Format
Output one line containing integers, representing the sequence after all operations.
5 5
1
2
3 2 4
4
3 1 5
5 4 3 2 1
Hint
Constraints
This problem uses bundled testdata.
subtask 1 (24 pts): .
subtask 2 (13 pts): There is no operation of type 3.
subtask 3 (63 pts): .
Sample Explanation
The operations applied to the sequence are:
Translated by ChatGPT 5