#abc279c. C - RANDOM
C - RANDOM
Score : points
问题描述
给定由#
和.
组成的模式和,每种模式都有行和列。
模式以个字符串的形式给出,其中的第个字符表示第行和第列的元素。模式也是如此。
判断是否可以通过重新排列的列使其与相等。
这里,对模式的列进行重新排列是按以下方式进行的:
- 选择一个的排列。
- 然后,对于满足的所有整数,同时执行以下操作:
- 对于满足的所有整数,同时将中第行和第列的元素替换为第行和列的元素。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given patterns and consisting of #
and .
, each with rows and columns.
The pattern is given as strings, and the -th character of represents the element at the -th row and -th column. The same goes for .
Determine whether can be made equal to by rearranging the columns of .
Here, rearranging the columns of a pattern is done as follows.
- Choose a permutation of .
- Then, for every integer such that , simultaneously do the following.
- For every integer such that , simultaneously replace the element at the -th row and -th column of with the element at the -th row and -th column.
Constraints
- and are integers.
- and are strings of length consisting of
#
and.
.
Input
The input is given from Standard Input in the following format:
Output
If can be made equal to , print Yes
; otherwise, print No
.
Sample Input 1
3 4
##.#
##..
#...
.###
..##
...#
Sample Output 1
Yes
If you, for instance, arrange the -rd, -th, -nd, and -st columns of in this order from left to right, will be equal to .
Sample Input 2
3 3
#.#
.#.
#.#
##.
##.
.#.
Sample Output 2
No
In this input, cannot be made equal to .
Sample Input 3
2 1
#
.
#
.
Sample Output 3
Yes
It is possible that .
Sample Input 4
8 7
#..#..#
.##.##.
#..#..#
.##.##.
#..#..#
.##.##.
#..#..#
.##.##.
....###
####...
....###
####...
....###
####...
....###
####...
Sample Output 4
Yes
update @ 2024/3/10 11:44:19