#abc264c. C - Matrix Reducing
C - Matrix Reducing
Score : points
问题陈述
给定两个矩阵:矩阵 具有 行和 列,矩阵 具有 行和 列。
- 对于所有满足条件 和 的整数对 ,矩阵 中第 行第 列的元素记为 。
- 对于所有满足条件 和 的整数对 ,矩阵 中第 行第 列的元素记为 。
你可以对矩阵 进行任意次数(包括可能的 次)以下操作,且顺序不限:
- 选择矩阵 中的任意一行并移除它。
- 选择矩阵 中的任意一列并移除它。
确定是否可以通过上述操作使矩阵 等于矩阵 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a matrix with rows and columns, and a matrix with rows and columns.
- For all integer pairs such that and , the element at the -th row and -th column of matrix is .
- For all integer pairs such that and , the element at the -th row and -th column of matrix is .
You may perform the following operations on the matrix any number of (possibly ) times in any order:
- Choose an arbitrary row of and remove it.
- Choose an arbitrary column of and remove it.
Determine if it is possible to make the matrix equal the matrix .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print Yes
if it is possible to make the matrix equal the matrix ; print No
otherwise. Note that the judge is case-sensitive.
Sample Input 1
4 5
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
2 3
6 8 9
16 18 19
Sample Output 1
Yes
Removing the -nd column from the initial results in:
1 3 4 5
6 8 9 10
11 13 14 15
16 18 19 20
Then, removing the -rd row from results in:
1 3 4 5
6 8 9 10
16 18 19 20
Then, removing the -st row from results in:
6 8 9 10
16 18 19 20
Then, removing the -th column from results in:
6 8 9
16 18 19
Now the matrix equals the matrix .
Thus, we can make the matrix equal the matrix by repeating the operations, so Yes
should be printed.
Sample Input 2
3 3
1 1 1
1 1 1
1 1 1
1 1
2
Sample Output 2
No
Regardless of how we perform the operations, we cannot make the matrix equal the matrix , so No
should be printed.
update @ 2024/3/10 11:09:15