#P1567F. One-Four Overload
One-Four Overload
No submission language available for this problem.
Description
Alice has an empty grid with rows and columns. Some of the cells are marked, and no marked cells are adjacent to the edge of the grid. (Two squares are adjacent if they share a side.)
Alice wants to fill each cell with a number such that the following statements are true:
- every unmarked cell contains either the number or ;
- every marked cell contains the sum of the numbers in all unmarked cells adjacent to it (if a marked cell is not adjacent to any unmarked cell, this sum is );
- every marked cell contains a multiple of .
The first line of input contains two integers and () — the number of rows and the number of columns in the grid, respectively.
Then lines follow, each containing characters. Each of these characters is either '.' or 'X' — an unmarked and a marked cell, respectively. No marked cells are adjacent to the edge of the grid.
Output "'NO" if no suitable grid exists. Otherwise, output "'YES"'. Then output lines of space-separated integers — the integers in the grid.
Input
The first line of input contains two integers and () — the number of rows and the number of columns in the grid, respectively.
Then lines follow, each containing characters. Each of these characters is either '.' or 'X' — an unmarked and a marked cell, respectively. No marked cells are adjacent to the edge of the grid.
Output
Output "'NO" if no suitable grid exists. Otherwise, output "'YES"'. Then output lines of space-separated integers — the integers in the grid.
Samples
Note
It can be shown that no such grid exists for the second test.