Problem A
Matrix Multiplication
Given three matrices $A$, $B$, and $C$ of size $n \cdot x$, $y \cdot m$, and $n \cdot m$, respectively, output:
-
“Inner matrix dimensions must agree” (without the quotes) if you cannot perform the matrix multiplication operation because of the quoted reason.
-
“WA” (without the quotes — “WA” stands from the keyword “Wrong Answer”) if the multiplication of matrix $A$ and $B$ does not produce matrix $C$.
-
“AC” (without the quotes — “AC” stands from the keyword “Accepted”) if the multiplication of matrix $A$ and $B$ correctly produces matrix $C$.
Input
The first line of input contains an integer $TC$ ($1 \leq TC \leq 77$), denoting the number of test cases.
Each test case first starts with a blank line (as a visual separator for human reader — this should not cause too much problem for your code), then four groups of data:
-
A line that contains four integers: $n$, $x$, $y$, and $m$ ($1 \leq n, x, y, m \leq 1000$; $TC \cdot 3 \cdot n \cdot m \leq 3*10^7$),
-
Then, $n$ rows of $x$ columns of integers between [$0$..$7$] that describe matrix $A$,
-
Followed by $y$ rows of $m$ columns of integers between [$0$..$7$] that describe matrix $B$, and
-
Finally by $n$ rows of $m$ columns of integers between [$0$..$max(x, y) \cdot 7 \cdot 7$] that describe matrix $C$.
Unfortunately for this problem, we need to explicitly provide the (big) input to you. Therefore you need to use Fast/Buffered I/O methods for this task.
Output
For each test case, print the required answer in one line.
Subtasks
-
($11$ Points): ($1 \leq n, x, y, m \leq 1$).
-
($29$ Points): ($1 \leq n, x, y, m \leq 77$).
-
($23$ Points): ($1 \leq n, x, y, m \leq 500$).
-
($37$ Points): No additional constraints.
Sample Input 1 | Sample Output 1 |
---|---|
2 1 1 1 1 7 7 49 1 1 1 1 7 7 48 |
AC WA |
Sample Input 2 | Sample Output 2 |
---|---|
3 2 1 2 3 1 7 2 5 1 2 5 1 2 5 1 14 35 7 2 1 1 3 1 7 2 5 1 2 5 1 14 35 6 2 1 1 3 1 7 2 5 1 2 5 1 14 35 7 |
Inner matrix dimensions must agree WA AC |