#C1609. List Operations
List Operations
List Operations
You are given an initial list of integers. You need to perform a series of operations on this list sequentially. The operations can be:
- add X Y: Add the integer Y to the element at index X. That is, if the current value is \(a_X\), it becomes \(a_X + Y\).
- mul X Y: Multiply the element at index X by the integer Y. That is, it updates as \(a_X \times Y\).
- print X: Print the current value of the element at index X.
All indices are 0-based. Process the operations in the given order and output the result of each print
operation on a new line.
inputFormat
The input is read from standard input and has the following format:
n m a0 a1 ... an-1 operation1 operation2 ... operationm
Here, n is the number of integers in the initial list, and m is the number of operations. Each operation is in one of the following forms:
add X Y
mul X Y
print X
outputFormat
For each print
operation encountered in the sequence, output the resulting integer on its own line to standard output.
5 3
1 2 3 4 5
add 2 10
mul 1 3
print 2
13