#C9949. Subarray Sum Parity
Subarray Sum Parity
Subarray Sum Parity
You are given an integer array \(B\) of size \(M\). You are then given \(Q\) queries. Each query consists of two integers \(L\) and \(R\) (1-indexed). For each query, compute the sum of the subarray \(B[L\ldots R]\) and determine whether the sum is even or odd.
You can use the prefix sum technique to efficiently compute the sum of any subarray in \(O(1)\) time after an \(O(M)\) preprocessing step. Specifically, if \(prefix[i]\) denotes the sum of the first \(i\) numbers, then the subarray sum from \(L\) to \(R\) is given by \(S = prefix[R] - prefix[L-1]\).
For each query, output "EVEN" if \(S\) is even, or "ODD" otherwise.
inputFormat
The input is read from standard input (stdin) and has the following format:
T M Q B[1] B[2] ... B[M] L1 R1 L2 R2 ... LQ RQ
Where:
- T is the number of test cases.
- For each test case, the first line contains two integers \(M\) (the size of the array) and \(Q\) (the number of queries).
- The second line contains \(M\) space-separated integers representing the array \(B\).
- Each of the next \(Q\) lines contains two integers \(L\) and \(R\) representing a query.
outputFormat
For each query, print a single line to standard output (stdout) containing either "EVEN" or "ODD" depending on the parity of the subarray sum.
## sample1
5 3
4 7 2 9 3
1 3
2 5
1 5
ODD
ODD
ODD
</p>