#P8747. [蓝桥杯 2021 省 B] 双向排序
[蓝桥杯 2021 省 B] 双向排序
Problem Description
Given a sequence $\left(a_{1}, a_{2}, \cdots, a_{n}\right)=(1,2, \cdots, n)$, that is, .
Xiao Lan will perform operations on this sequence. Each operation is either sorting in descending order, or sorting in ascending order.
Please output the sequence after all operations are completed.
Input Format
The first line contains two integers , representing the length of the sequence and the number of operations.
The next lines describe the operations. The -th line contains two integers , representing the operation type and parameter.
When , it means sorting in descending order.
When , it means sorting in ascending order.
Output Format
Output one line containing integers, separated by a single space, representing the sequence after all operations are completed.
3 3
0 3
1 2
0 2
3 1 2
Hint
[Sample Explanation]
The original sequence is .
After step 1, it becomes .
After step 2, it becomes .
After step 3, it becomes , the same as after step 2, because the first two numbers are already in descending order.
[Test Case Scale and Constraints]
For of the test cases, .
For of the test cases, .
For all test cases, , , .
Lanqiao Cup 2021, First Round Provincial Contest, Group B, Problem I.
Translated by ChatGPT 5