2018年上海金馬五校程式設計競賽 Problem O : ±1 Matrix
阿新 • • 發佈:2019-02-18
Description
A matrix in mathematics is a rectangular array of numbers arranged in rows and columns. Given an n×m matrix A and an m×k matrix B, which only contain +1 and -1.
Please design a quick algorithm to calculate the result of multiplying these two matrices. Note that the result is an n
Input
There are multiple test cases (no more than 10).
For each test case, there are several lines.
The first line contains three integers n, m and k (2 ≤ n, m, k < 1111), which correspond to the sizes of matrices A and Bdescribed above.
Next is a blank line.
The next n lines describe the matrix A
Next is a blank line.
The next m lines describe the matrix B. Each of the m lines has k space-separated +1 or -1.
There is a blank line between every two test cases, and there is no extra empty line at the beginning or end of the input.
Output
For each test case, output an n
You should output n lines. Each line contains k space-separated integers.
Sample Input
2 3 3 -1 -1 1 -1 1 -1 1 -1 1 1 1 1 1 1 1 2 2 2 -1 1 1 1 -1 -1 -1 1
Sample Output
-1 1 -1 -1 1 -1 0 2 -2 0