#CCBCHBAHAI0000056. Bài kiểm tra cuối Ch32 - Array Mastery (Chapter 32 Final Test - Array Mastery)
Bài kiểm tra cuối Ch32 - Array Mastery (Chapter 32 Final Test - Array Mastery)
Chapter 32 Final Test - Array Mastery (Bài kiểm tra cuối Ch32 - Array Mastery)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Maintain a fixed-capacity array of capacity with logical size , so the active sequence is and .
Process commands in order:
1 p: print , with .2 p x: assign .3: reverse the logical sequence.4 p x: insert before position , with .5 p: delete position , with .6 x: print the smallest index containing , or .7: with , print , , and .
All positions are 0-based. Updates affect all later commands.
Input
The first line contains . The second line contains the initial integers (empty if ). The next lines contain commands.
Output
For every command of type 1, 6, or 7, print one result line.
Subtask
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Example
Input
5 3 7
4 1 9
1 1
4 1 7
6 9
3
2 0 5
7
5 2
Output
1
3
17 1 7
Explanation
The sample follows the definitions and rules above.