#abc298b. B - Coloring Matrix
B - Coloring Matrix
Score : points
问题描述
给定两个 × 的矩阵 和 ,其中每个元素为0或1。
令 和 分别表示矩阵 和 中第 行和第 列的元素。
确定是否存在一种方式旋转矩阵 ,使得对于所有满足 的整数对 ,都有 。
这里,旋转矩阵 意味着执行零次或多次以下操作:
- 对于所有满足 的整数对 ,同时将 替换为 。
 
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given -by- matrices  and  where each element is  or .
Let  and  denote the element at the -th row and -th column of  and , respectively.
Determine whether it is possible to rotate  so that  for every pair of integers  such that .
Here, to rotate  is to perform the following operation zero or more times:
- for every pair of integers such that , simultaneously replace with .
 
Constraints
- Each element of and is or .
 - All values in the input are integers.
 
Input
The input is given from Standard Input in the following format:
Output
If it is possible to rotate  so that  for every pair of integers  such that , print Yes; otherwise, print No.
Sample Input 1
3
0 1 1
1 0 0
0 1 0
1 1 0
0 0 1
1 1 1
Sample Output 1
Yes
Initially, is :
0 1 1
1 0 0
0 1 0
After performing the operation once, is :
0 1 0
1 0 1 
0 0 1
After performing the operation once again, is :
0 1 0
0 0 1
1 1 0
Here,  for every pair of integers  such that , so you should print Yes.
Sample Input 2
2
0 0
0 0
1 1
1 1
Sample Output 2
Yes
Sample Input 3
5
0 0 1 1 0
1 0 0 1 0
0 0 1 0 1
0 1 0 1 0
0 1 0 0 1
1 1 0 0 1
0 1 1 1 0
0 0 1 1 1
1 0 1 0 1
1 1 0 1 0
Sample Output 3
No
update @ 2024/3/10 12:21:40