#K44562. Determine Parity of Subarray Sums

    ID: 27559 Type: Default 1000ms 256MiB

Determine Parity of Subarray Sums

Determine Parity of Subarray Sums

You are given an array of n integers and a number q representing the number of changes allowed (which you do not need to use). Your task is to answer m queries. Each query provides two indices l and r, and you need to determine whether the sum of the subarray from index l to r is even or odd.

Input Format:

  • The first line contains two integers n and q where \( n \) is the number of elements in the array and \( q \) is the number of changes allowed (not used in the computation).
  • The second line contains \( n \) space-separated integers representing the array elements.
  • The third line contains an integer \( m \), the number of queries.
  • The following \( m \) lines each contain two integers \( l \) and \( r \) (1-indexed) representing the range of the subarray.

Output Format:

For each query, output a single line containing either even or odd depending on the parity of the sum of the corresponding subarray.

Note: The sum and parity determination can be formally described by the formula:

[ S = \sum_{i=l}^{r} a_i, \quad \text{and output } \begin{cases} \text{even} & \text{if } S \equiv 0 \pmod{2}, \ \text{odd} & \text{if } S \equiv 1 \pmod{2}. \end{cases} ]

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  • The first line contains two integers \( n \) and \( q \).
  • The second line contains \( n \) space-separated integers representing the array.
  • The third line contains an integer \( m \), denoting the number of queries.
  • The next \( m \) lines each contain two space-separated integers \( l \) and \( r \).

outputFormat

The output should be printed to standard output (stdout). For each query, print a single line with either even or odd indicating the parity of the subarray sum.

## sample
5 2
4 3 1 6 5
3
1 3
2 4
1 5
even

even odd

</p>