Quantum Operations
Time limit1sMemory limit128 MB
Compute the tensor product of several integer matrices and report its element extremes plus maximum and minimum row and column sums.
- Level
Medium5 of 10
- Topics
- Implementation, Matrix, Math, Prefix sum
- Solved
- No attempts yet
Problem
Quantum computing is currently a hot topic in research. If they can be built, quantum computers will be able to perform certain computing tasks far faster than any computer that exists today. Fortunately, you will not need a quantum computer to solve this problem.
A fundamental concept in quantum computing is the quantum operation. A quantum operation can essentially be thought of as a matrix. Moreover, if you perform two quantum operations in parallel on separate quantum data, the combination can be thought of as one larger quantum operation. In terms of matrices, the matrix that results from combining two matrices in parallel is called the tensor product of the two matrices (written with the symbol ). This is different from the ordinary matrix product you may have learned about.
Given two matrices and (each essentially a two-dimensional array), we write their individual elements as follows:
Here matrix has size ( rows and columns), and matrix has size .
The tensor product of these two matrices is an matrix (with rows and columns) that looks like:
where denotes the block obtained by multiplying every element of by .
Note that the tensor product is not commutative: changing the order of the matrices may change the result ().
For more than two matrices, we define . The exact grouping does not matter, because the tensor product is associative.
Your task is to compute the tensor product of two or more given matrices and report several statistics about it.
Input
The first line contains the number of matrices, , a positive integer. Then follow blocks of lines describing the matrices in order.
In each block, the first line contains two positive integers and , separated by a space, giving the number of rows and columns respectively. The next lines describe the rows in order; each of these lines contains integers separated by spaces.
Output
Output six integers, one per line, in the following order:
- the maximum element of the tensor product
- the minimum element of the tensor product
- the maximum row sum (the sum of the entries in a row)
- the minimum row sum
- the maximum column sum (the sum of the entries in a column)
- the minimum column sum
You may assume that the tensor product matrix has no more than rows and no more than columns.