#C85. Max Ruby Game Outcome
Max Ruby Game Outcome
Max Ruby Game Outcome
You are given a number of test cases. For each test case, you are provided with a matrix of integers. Your task is to compute the total sum of all the integers in the matrix. If the total sum is an odd number, print WIN
; if it is even, print DRAW
.
The game is named after the famous characters Max and Ruby. Both players play optimally, and the outcome is determined solely by the parity of the sum of the matrix elements.
Note: The input is read from standard input (stdin) and the output is printed to standard output (stdout).
Below is the summary of the problem:
- If the sum of matrix elements is odd, output
WIN
. - If the sum is even, output
DRAW
.
The mathematical formulation for this is: $$\text{result} = \begin{cases}\text{WIN} & \text{if } \left(\sum_{i=1}^{n}\sum_{j=1}^{m} a_{ij}\right) \bmod 2 = 1,\\ \text{DRAW} & \text{if } \left(\sum_{i=1}^{n}\sum_{j=1}^{m} a_{ij}\right) \bmod 2 = 0.\end{cases}$$
inputFormat
The input begins with a single integer t
(the number of test cases). Each test case is described as follows:
- The first line of each test case contains two space-separated integers
n
andm
representing the number of rows and columns of the matrix. - The next
n
lines each containm
space-separated integers, representing the rows of the matrix.
You need to process each test case and output the result on a new line.
outputFormat
For each test case, output a single line containing either WIN
or DRAW
depending on the parity of the sum of the matrix elements.
1
2 2
1 2
3 4
DRAW
</p>