QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100 難易度: [表示] ハック可能 ✓

#18881. Dev, Please Add This!

統計

Jaemin developed a puzzle game app.

A ball is placed on a cell in a grid. You can roll the ball upwards, downwards, to the left, or to the right. The ball rolls in that direction until it hits a wall or the boundary. Some cells have stars on them, and the player obtains the star when the ball stops there or passes through it. The objective of the game is to obtain all stars in the grid.

This app has a level editor where players can make and share their own levels. One day, someone suggested: “Please add a feature to check if my level is possible to solve!” Easier said than done, right?

Input

The first line of the input consists of two integers, $H$ (height) and $W$ (width). ($1 \leq H, W \leq 50$) Each of the next $H$ lines contains a string of legnth $W$ which describes each row of the grid. “#” means a wall, “.” means a blank space, “O” means a ball, and “*” means a star. There is exactly one ball and at least one star on the grid.

Output

Print “YES” if it is possible to obtain all stars, otherwise “NO”.

Examples

Input 1

3 7
#..O..#
#.###.#
*..#..*

Output 1

NO

Input 2

6 6
*..*##
..O...
*..*#.
####*.
......
.....#

Output 2

YES

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#3141EditorialOpenNew Editorial for Problem #18881nullptr_qwqView

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.