logo AlgoBeat OnlineJudge
登录 注册

#217671. [ECNA 2024] Oooh I See

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Captain O'Capten has hidden some treasure and created a map to mark where it is buried. Rather than using 'X' to mark the spot, he has decided to obfuscate the location by using a grid of uppercase O (the letter O) characters and 0 (the number 0) characters. The treasure's position is given by the location of a 0 character surrounded on all sides by O characters. That is, a 0 character with an O immediately above, below, to the left, to the right, diagonally above to the left, diagonally above to the right, diagonally below to the left, and diagonally below to the right.

Captain O'Capten wants to recover the location of his treasure but he is finding his map hard to read (huh, go figure). Help Captain O'Capten find the location of his treasure, or exclaim Oh no! if such a location is not marked on the map or there is more than one such location.

输入格式

The first line contains two integers and (), where indicates the number of rows and indicates the number of columns of characters in the map. Rows are numbered to , top to bottom, and columns are numbered to , left to right. This is followed by lines, each with characters, where each character is either O or 0.

输出格式

If there is no 0 character surrounded on all sides by O characters, then output one line consisting of the exclamation, Oh no!. If there is more than one 0 character surrounded on all sides by O characters, then output one line consisting of the exclamation, Oh no! N locations, with the number of locations instead of N. If there is exactly one 0 character surrounded on all sides by O characters, then output one line containing two integers. The first integer is the index of the row of the 0 character and the second integer is the index of the column of the 0 character.

样例

样例输入 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!