#K14266. Taco Sequence Operations

    ID: 24097 Type: Default 1000ms 256MiB

Taco Sequence Operations

Taco Sequence Operations

Joe is a software developer working with sequences of integers. He is given an array A of N integers and must perform K operations. Each operation is one of the following two types:

  • E X Y: Replace the value at the X-th position in the array with Y.
  • S L R: Compute the sum of all even numbers in the subarray from position L to R (inclusive).

For each S operation, output the computed sum on a new line. Note that the update operations affect the array permanently.

The even number condition is mathematically represented as: $$x\bmod 2 = 0$$ for an element \(x\).

Follow the input/output format strictly as described below.

inputFormat

The input is read from STDIN. The first line contains two integers N and K, separated by a space. The second line contains N space-separated integers representing the array A. The next K lines each represent an operation in one of the following forms:

  • E X Y
  • S L R

For operation 'E X Y', update the element at the X-th position with Y. For operation 'S L R', compute and output the sum of even numbers in the subarray from index L to R (inclusive).

outputFormat

For each 'S' operation, output the computed sum on a new line to STDOUT.## sample

6 4
3 2 7 4 6 9
S 2 5
E 3 8
S 1 6
S 4 6
12

20 10

</p>