#C9613. Query Sequence Operations
Query Sequence Operations
Query Sequence Operations
You are given a sequence of integers and a list of queries. Each query can be one of the three types:
- Type 1: Reverse the subsequence from index \(L\) to \(R\) (inclusive).
- Type 2: Replace the element at index \(L\) with the value \(X\).
- Type 3: Compute the sum of the subsequence from index \(L\) to \(R\) (inclusive).
All indices are 1-based. The queries must be processed in the order they are given, and for each query of Type 3 you should output the computed sum.
inputFormat
The input is provided via standard input (stdin) in the following format:
- An integer \(n\) representing the number of elements in the sequence.
- A line with \(n\) space-separated integers denoting the sequence.
- An integer \(q\) representing the number of queries.
- \(q\) lines each describing a query. The format for a query is one of the following:
- For Type 1:
1 L R
- For Type 2:
2 L X
- For Type 3:
3 L R
- For Type 1:
outputFormat
For each query of Type 3, output a single line containing the sum of the specified subsequence.
## sample5
5 3 8 1 2
5
3 1 3
1 2 4
3 1 3
2 2 10
3 1 3
16
14
23
</p>