#abc300b. B - Same Map in the RPG World
B - Same Map in the RPG World
Score : points
问题描述
高桥正在开发一款RPG游戏。他决定编写一段代码来检查两个地图是否相等。
我们有网格 和 ,它们都有 行和 列。每个格子上都写有一个符号#
或.
。
在网格 和 中,从上到下第 行、从左到右第 列的格子上的符号分别表示为 和 。
以下两种操作被称为垂直平移和水平平移。
- 对于所有 同时执行以下操作:
- 同时将 替换为 。
- 对于所有 同时执行以下操作:
- 同时将 替换为 。
是否存在一对非负整数 满足以下条件?如果存在则输出 Yes
,否则输出 No
。
- 应用 次垂直平移和 次水平平移后, 等于 。
这里,若对于所有满足 和 的整数对 ,均有 ,则称 等于 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi is developing an RPG. He has decided to write a code that checks whether two maps are equal.
We have grids and with horizontal rows and vertical columns. Each cell in the grid has a symbol #
or .
written on it.
The symbols written on the cell at the -th row from the top and -th column from the left in and are denoted by and , respectively.
The following two operations are called a vertical shift and horizontal shift.
- For each , simultaneously do the following:
- simultaneously replace with .
- For each , simultaneously do the following:
- simultaneously replace with .
Is there a pair of non-negative integers that satisfies the following condition? Print Yes
if there is, and No
otherwise.
- After applying a vertical shift times and a horizontal shift times, is equal to .
Here, is said to be equal to if and only if for all integer pairs such that and .
Constraints
- is
#
or.
, and so is . - and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if there is a conforming integer pair ; print No
otherwise.
Sample Input 1
4 3
..#
...
.#.
...
#..
...
.#.
...
Sample Output 1
Yes
By choosing , the resulting is equal to .
We describe the procedure when is chosen. Initially, is as follows.
..#
...
.#.
...
We first apply a vertical shift to make as follows.
...
.#.
...
..#
Then we apply another vertical shift to make as follows.
.#.
...
..#
...
Finally, we apply a horizontal shift to make as follows, which equals .
#..
...
.#.
...
Sample Input 2
3 2
##
##
#.
..
#.
#.
Sample Output 2
No
No choice of makes equal .
Sample Input 3
4 5
#####
.#...
.##..
..##.
...##
#...#
#####
...#.
Sample Output 3
Yes
Sample Input 4
10 30
..........##########..........
..........####....###.....##..
.....##....##......##...#####.
....####...##..#####...##...##
...##..##..##......##..##....#
#.##....##....##...##..##.....
..##....##.##..#####...##...##
..###..###..............##.##.
.#..####..#..............###..
#..........##.................
................#..........##.
######....................####
....###.....##............####
.....##...#####......##....##.
.#####...##...##....####...##.
.....##..##....#...##..##..##.
##...##..##.....#.##....##....
.#####...##...##..##....##.##.
..........##.##...###..###....
...........###...#..####..#...
Sample Output 4
Yes
update @ 2024/3/10 08:23:16