CF1162B Double Matrix
题目描述
【问题描述】
如果矩阵每行从左到右的所有数字严格递增,则称行严格递增,如果从上到下的所有数字都严格递增,则列严格递增。如果所有行和列都严格递增,则称矩阵为递增矩阵。
给出两个包含整数的n×m矩阵A和B,你可以尝交换A_ij和B_ij的值(即交换A、B矩阵同一位置的值)使矩阵A和B变成递增矩阵。
输入格式
第一行包含两个整数n和m(1≤n,m≤50)表示每个矩阵的行数和列数。
接下来n行表示A矩阵,每行m个数(A_i1、A_i2…A_im)(1≤A_ij 1≤10^9)。
接下来n行表示B矩阵,每行m个数(B_i1、B_i2…B_im)(1≤A_ij 1≤10^9)。
输出格式
如果能使用A、B变成递增矩阵的,输出Possible,否则输出Impossible。
说明/提示
The first example, we can do an operation on the top left and bottom right cells of the matrices. The resulting matrices will be $ \begin{bmatrix} 9&10\\ 11&12\\ \end{bmatrix} $ and $ \begin{bmatrix} 2&4\\ 3&5\\ \end{bmatrix} $ .
In the second example, we don't need to do any operations.
In the third example, no matter what we swap, we can't fix the first row to be strictly increasing in both matrices.