2073: 序列翻转

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:79 Solved:13

Description

给定一个N个数的数组,M次操作。每次操作将数组的一段翻转,求最后的数组。

Input

第一行两个整数N,M(N,M≤1000)含义见试题描述。
第二行N个整数,表示原来的数组。
接下来M行,每行两个整数X,Y(1≤X≤Y≤N),表示翻转区间[X,Y]。

Output

一行N个整数,表示操作后的数组。

Sample Input Copy

5 2
1 2 3 4 5
2 4
4 5

Sample Output Copy

1 4 3 5 2

HINT

vector  请使用Reverse函数