UTS Open '24 P5 - Parity Challenge
View as PDFSteven is learning about even and odd numbers in math class! His teacher, Todd, has written a long expression with  numbers, 
, on the chalkboard. Between each number is either an addition 
+ or multiplication x sign.
As part of a learning exercise, Todd has challenged the students to quickly determine whether variations of the expression are equal to an even or odd number. Specifically, Todd has given the students  events of three types:
V i- update the value ofto
.
O j- update theoperation to
xif it is currently a+, and vice versa.Q l r- Todd asks you what the parity of the expression becomes if you place an opening bracket to the left ofand a closing bracket to the right of
. Recall that calculations inside of brackets are done first, and that multiplication is done before addition. Note that the brackets are not actually added and are not present in future events.
Can you write a program to help Steven conquer the Parity Challenge?
Constraints
Subtask 1 [30%]
There are only events of type Q.
Subtask 2 [70%]
No additional constraints.
Input Specification
The first line of input contains two integers,  and 
, the number of numbers on the chalkboard and the number of events.
The next line of input contains  space-separated integers, 
, the numbers initially on the chalkboard.
The third line of input contains  characters, with the 
 character being either 
+ for addition or x for multiplication, indicating the operation initially between  and 
.
The final  lines of input contain events in one of the following formats:
V i- update the value ofto
.
O j- update theth operation to
xif it is currently a+, and vice versa.Q l r- Determine the parity of the expression if you place an opening bracket to the left ofand a closing bracket to the right of
.
Output Specification
For each event of type Q, output one line containing even if the parity of the expression is even after adding the brackets, and odd otherwise.
Sample Input
5 6
3 1 4 1 5
+++x
Q 1 2
O 2
Q 3 4
Q 5 5
V 5
Q 3 4
Sample Output
odd
even
even
odd
Explanation for Sample
This is the initial expression:
The first event is a query, with brackets around :
 
odd
The second event updates operation  from 
+ to x:
The third event places brackets around :
 
even
The fourth event places brackets around :
 
even
The fifth event increments  from 
 to 
:
The final event places brackets around :
 
odd
Comments