#P3391. 【模板】文艺平衡树
【模板】文艺平衡树
Description
You need to implement a data structure (you can refer to the title) to maintain an ordered sequence.
It must support the following operation: reverse a segment. For example, if the original ordered sequence is , and the reversed segment is , then the result is .
Input Format
The first line contains two positive integers , denoting the length of the sequence and the number of operations. Initially, the -th element of the sequence is .
Then follow lines, each containing two positive integers , denoting the segment to reverse.
Output Format
Output one line with positive integers, which is the result after applying reversals to the original sequence.
5 3
1 3
1 3
1 4
4 3 2 1 5
Hint
Constraints
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号