eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Minesweeper

Minesweeper

\includegraphics{https://static.e-olymp.com/content/35/351f390e076846162add9e9e0ecf245908dfdf5d.jpg} It is not surprising that you have played the Minesweeper game at least once. In this game, the player is initially presented with a grid (minefield) of squares. Some randomly selected squares, unknown to the player, are designated to contain mines. A square is unsafe if it contains a mine. Otherwise, it is called safe. The game is played by revealing the squares of the grid, typically by mouse clicks. If an unsafe square is revealed, the player loses the game. Otherwise, a digit is revealed in the safe square, indicating the number of adjacent squares (out of the possible eight) that are unsafe. In typical implementation, if this number is zero, the square appears blank, and the surrounding squares are automatically also revealed. In a variant of this game, the number of unsafe squares is given at the beginning of the game but in our variant this number is hidden. The player wins if he can reveal all safe squares. For a given minefield, your job is to find out whether the minefield can be deterministically cleaned with starting from the given start square, i.e. until all safe squares are not revealed, at each step we can find more safe squares just using the numbers appearing on revealed squares (not by clicking squares randomly.) \InputFile There are multiple test cases in the input. Each test case starts with a line containing two non-negative integers \textbf{n} and \textbf{m} not exceeding \textbf{10} where \textbf{n} and \textbf{m} are the number of rows and columns of the minefield. Each of the next \textbf{n} lines contains a string of size \textbf{m} consisting of \{'\textbf{+}', '\textbf{*}', '\textbf{-}'\}. Character '\textbf{-}' denotes a blank square, '\textbf{*}' denotes an unsafe square and '\textbf{+}' denotes the starting square which by default is safe. There is exactly one '\textbf{+}' in each test case. The input terminates with "\textbf{0 0}" which should not be processed. \OutputFile For each test case, output "\textbf{Yes}" if the given minefield can be deterministically cleaned. Otherwise, output "\textbf{No}".
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
1 3
-+*
3 4
*--+
**--
*--*
3 4
***-
*---
*--+
0 0
Выходные данные #1
No
No
Yes
Источник 11th Iran Internet Programming Contest, 28 November, 2013 (7 Azar, 1392)