QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 512 MB مجموع النقاط: 100

#18343. 循环移位迷宫

الإحصائيات

我们将迷宫定义为一个由网格组成的矩形区域,每个网格可以是空地或墙壁。人们可以沿着四个方向从一个空地移动到其相邻的空地。

如果可以通过在四个方向上移动,从任意一个空地到达其他任意一个空地,则称该迷宫是连通的。

原本有一个大小为 $n \times m$ 的连通迷宫。它被循环向下移动了若干行,并循环向右移动了若干列,但没有人知道具体的偏移量。请找出所有可能的偏移量。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 200$),表示迷宫的大小。

接下来的 $n$ 行,每行包含 $m$ 个字符 .#,分别表示空地和墙壁。

迷宫中至少包含一个空地。

输出格式

第一行输出一个整数 $k$ ($0 \le k \le n \cdot m$),表示可能的偏移量数量。

接下来的 $k$ 行,每行输出两个整数 $r_i$ 和 $c_i$ ($0 \le r_i < n, 0 \le c_i < m$),分别表示原迷宫循环向下移动的行数和循环向右移动的列数。数对 $(r_i, c_i)$ 应当按照字典序输出。在这些情况中,原迷宫必须是连通的。

样例

输入格式 1

5 6
..####
.###..
...#.#
##...#
.###..

输出格式 1

9
0 2
0 3
0 4
1 2
1 3
1 4
4 2
4 3
4 4

输入格式 2

8 10
##########
..........
#.####..##
..###..##.
#....##...
######..##
....###...
....###...

输出格式 2

2
0 5
1 5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.