QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 2048 MB 満点: 100

#9762. 噢,我明白了

統計

O'Capten 船长藏了一些财宝,并绘制了一张地图来标记埋藏地点。他没有使用“X”来标记位置,而是决定通过使用由大写字母 O 和数字 0 组成的网格来混淆视听。财宝的位置由一个被 8 个 O 字符包围的 0 字符给出。也就是说,该 0 字符的上方、下方、左侧、右侧、左上角、右上角、左下角和右下角都必须是 O 字符。

O'Capten 船长想要找回他的财宝,但他发现地图很难阅读。请帮助 O'Capten 船长找到财宝的位置;如果地图上没有标记这样的位置,或者存在多于一个这样的位置,请输出 Oh no!。

输入格式

第一行包含两个整数 $r$ 和 $c$ ($1 \le r, c \le 50$),其中 $r$ 表示地图的行数,$c$ 表示地图的列数。行号从上到下编号为 $1$ 到 $r$,列号从左到右编号为 $1$ 到 $c$。接下来有 $r$ 行,每行包含 $c$ 个字符,每个字符要么是 O,要么是 0。

输出格式

如果没有 0 字符被 8 个 O 字符包围,则输出一行 Oh no!。如果有多于一个 0 字符被 8 个 O 字符包围,则输出一行 Oh no! N locations,其中 N 为找到的位置数量。如果恰好有一个 0 字符被 8 个 O 字符包围,则输出一行包含两个整数的内容。第一个整数是该 0 字符所在的行号,第二个整数是该 0 字符所在的列号。

样例

样例输入 1

3 6
OO0OOO
00OO0O
0O0OOO

样例输出 1

2 5

样例输入 2

5 3
OOO
O0O
OOO
O0O
OOO

样例输出 2

Oh no! 2 locations

样例输入 3

4 4
OOO0
0O0O
OOO0
0O0O

样例输出 3

Oh no!

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.