Oooh I See

면접 대비

시간 제한1초메모리 제한2048 MB

요약
격자에서 여덟 방향이 모두 'O'인 '0' 칸을 찾아, 없거나 여러 개면 오류 메시지를 출력한다.
난이도

쉬움10점 중 3점

유형
배열, 구현, 완전 탐색, 시뮬레이션
정답자
아직 제출이 없습니다

문제

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 88 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 rr and cc (1≤r,c≤501\leq r,c \leq 50), where rr indicates the number of rows and cc indicates the number of columns of characters in the map. Rows are numbered 11 to rr, top to bottom, and columns are numbered 11 to cc, left to right. This is followed by rr lines, each with cc characters, where each character is either O or 0.

출력

If there is no 0 character surrounded on all sides by 88 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 88 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 88 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.

예제3

  1. 예제 1

    입력
    3 6
    OO0OOO
    00OO0O
    0O0OOO
    
    예상 출력
    2 5
    
  2. 예제 2

    입력
    5 3
    OOO
    O0O
    OOO
    O0O
    OOO
    
    예상 출력
    Oh no! 2 locations
    
  3. 예제 3

    입력
    4 4
    OOO0
    0O0O
    OOO0
    0O0O
    
    예상 출력
    Oh no!