#K63487. Sequence Modification
Sequence Modification
Sequence Modification
You are given an integer sequence of length \(n\) along with \(q\) commands. Each command is of one of the following two types:
- Type 1: "1 x v" — Update the \(x\)-th element of the sequence to \(v\). In other words, set \(a_x = v\).
- Type 2: "2 l r" — Reverse the subarray from index \(l\) to \(r\) (both inclusive). That means the segment \(a_l, a_{l+1}, \ldots, a_r\) becomes \(a_r, a_{r-1}, \ldots, a_l\).
Your task is to apply all the commands in the given order and output the final modified sequence.
Note: Use 1-indexed positions for the commands.
inputFormat
The input is read from standard input (stdin) and has the following format:
- An integer \(n\) representing the number of elements in the sequence.
- \(n\) space-separated integers representing the initial sequence.
- An integer \(q\) representing the number of commands.
- \(q\) lines, each line is a command in one of the two forms described above.
outputFormat
Print the final modified sequence to the standard output (stdout) as a single line of \(n\) space-separated integers.
## sample5
1 2 3 4 5
3
1 3 10
2 2 4
1 5 6
1 4 10 2 6