#C882. Array Manipulation

    ID: 52844 Type: Default 1000ms 256MiB

Array Manipulation

Array Manipulation

You are given an array of integers and a list of operations to modify the array. Each operation is formatted as \(\texttt{op x y}\) where \(\texttt{op}\) is either \(\texttt{add}\) or \(\texttt{mult}\), \(x\) is a 1-indexed position in the array, and \(y\) is an integer. For an operation \(\texttt{add x y}\), add \(y\) to the element at position \(x\). For an operation \(\texttt{mult x y}\), multiply the element at position \(x\) by \(y\). Execute the operations in the given order and output the final state of the array.

Note: The input is provided via standard input and the output should be printed to standard output.

inputFormat

The input consists of the following lines:

  • The first line contains an integer \(n\) \((1 \le n \le 10^5)\): the number of elements in the array.
  • The second line contains \(n\) space-separated integers: the initial array.
  • The third line contains an integer \(m\) \((0 \le m \le 10^5)\): the number of operations.
  • The next \(m\) lines each contain an operation string in the format "op x y", where \(\texttt{op}\) is either "add" or "mult", \(x\) is the 1-indexed position, and \(y\) is an integer.

outputFormat

Output a single line containing the final state of the array as space-separated integers.

## sample
5
1 2 3 4 5
3
add 2 3
mult 4 2
add 1 1
2 5 3 8 5