아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Plus from Picture

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

요약
점과 별로 이루어진 h x w 격자가 주어질 때, 별들이 하나의 중심과 네 방향 팔을 가진 정확히 하나의 더하기 모양을 이루는지 판별한다.
난이도

보통10점 중 4점

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

문제

You have a given picture with size w×hw \times h. Determine if the given picture has a single "+" shape or not. A "+" shape is described below:

  • A "+" shape has one center nonempty cell.
  • There should be some (at least one) consecutive non-empty cells in each direction (left, right, up, down) from the center. In other words, there should be a ray in each direction.
  • All other cells are empty.

Find out if the given picture has single "+" shape.

입력

The first line contains two integers hh and ww (1≤h1 \le h, w≤500w \le 500) --- the height and width of the picture.

The ii-th of the next hh lines contains string s_is\_{i} of length ww consisting "." and "*" where "." denotes the empty space and "*" denotes the non-empty space.

출력

If the given picture satisfies all conditions, print "YES". Otherwise, print "NO".

힌트

In the first example, the given picture contains one "+".

In the second example, two vertical branches are located in a different column.

In the third example, there is a dot outside of the shape.

In the fourth example, the width of the two vertical branches is 22.

In the fifth example, there are two shapes.

In the sixth example, there is an empty space inside of the shape.

예제6

  1. 예제 1

    입력
    5 6
    ......
    ..*...
    .****.
    ..*...
    ..*...
    
    예상 출력
    YES
    
  2. 예제 2

    입력
    3 5
    ..*..
    ****.
    .*...
    
    예상 출력
    NO
    
  3. 예제 3

    입력
    7 7
    .......
    ...*...
    ..****.
    ...*...
    ...*...
    .......
    .*.....
    
    예상 출력
    NO
    
  4. 예제 4

    입력
    5 6
    ..**..
    ..**..
    ******
    ..**..
    ..**..
    
    예상 출력
    NO
    
  5. 예제 5

    입력
    3 7
    .*...*.
    ***.***
    .*...*.
    
    예상 출력
    NO
    
  6. 예제 6

    입력
    5 10
    ..........
    ..*.......
    .*.******.
    ..*.......
    ..........
    
    예상 출력
    NO