- Permutation Transformer
Time Limit:2000MS Memory Limit:0KB 64bit IO Format:%lld
& %llu
Submit Status Practice UVA
11922
Appoint description:
Description
Permutation Transformer
Write a program to transform the permutation 1, 2, 3,..., n according to m instructions. Each instruction (a, b) means
to take out the subsequence from the a-th to the b-th element, reverse it, then append it to the end.
Input
There is only one case for this problem. The first line contains two integers n and m ( 1n, m100,
000). Each of the next m lines contains an instruction consisting of two integers a and b ( 1abn).
Output
Print n lines, one for each integer, the final permutation.
Explanation of the sample below
Instruction (2,5): Take out the subsequence {2,3,4,5}, reverse it to {5,4,3,2}, append it to the remaining permutation {1,6,7,8,9,10}
Instruction (4,8): The subsequence from the 4-th to the 8-th element of {1,6,7,8,9,10,5,4,3,2} is {8,9,10,5,4}. Take it out, reverse it, and you'll get the sample output.
Warning: Don't use cin, cout for this problem, use faster i/o methods e.g scanf, printf.