No.179 Two-Coloring
Problem Statement
There is a rectangle consisting of cells, with height $H$ and width $W$. Each cell is painted white or black.
yuki-kun has decided to repaint all of the black cells either red or blue. He also wants to paint at least 1 cell in each of red and blue, and to make the cells painted red and the cells painted blue coincide by a translation.
Print "YES" if the painting yuki-kun wants is possible, and "NO" if it is impossible. (The "" are not needed.)
Note: A single cell cannot be painted with more than one color. yuki-kun does not repaint white cells.
Input
$H$ $W$ $S_1$ $S_2$ $\vdots$ $S_H$
The first line contains $H$ and $W$, separated by a space.
Each of the following $H$ lines contains a string $S_i$ of length $W$, representing how the $i$-th row of cells is painted.
If the $j$-th character of $S_i$ is "#", the cell at row $i$, column $j$ is painted black; if it is ".", the cell is painted white. (The "" are not included.)
$1 \leq H \leq 50$
$1 \leq W \leq 50$
$S_i$ is a string consisting only of "#" and ".". (The "" are not included.)
Output
Print "YES" or "NO". (The "" are not needed.)
Print a newline at the end.
Sample
Sample 1
Input
3 3 ##. ### .#.
Output
YES
The cells can be painted as follows, so print "YES".
Sample 2
Input
5 3 .#. .#. .#. .#. .#.
Output
NO
No way of painting makes them coincide. Therefore, print "NO".
Sample 3
Input
3 9 ######... #.####.#. ######...
Output
YES
The cells can be painted as follows, so print "YES".
The original painting of the cells may have holes or separated parts.
The painting into red and blue may also have holes or separated parts.
Sample 4
Input
3 5 #...# ##.## #...#
Output
NO
Note that the painted cells must coincide by translation only.
Rotation and reflection are not allowed.
Sample 5
Input
5 8 ###..... #.####.. ..####.. ..####.# .....###
Output
YES
Sample 6
Input
23 33 ...............##................ ...........##########............ .......##################........ ...##########################.... .##....##################....##.. .######....##########....######.. .##########....##....##########.. .##....########..##############.. .######....####..##############.. .##############..##############.. .##############..##############.. .##############..##############.. ...############..############.... .......########..########........ ...........####..####............ ...............##................ ................................. ........#...#...........#........ ........#...............#........ #.#.#.#.#.#.#.###.###.###.###.#.# #.#.#.#.##..#.#...#.#.#.#.##..##. .#..###.#.#.#.###.###.###.###.#.. #................................
Output
NO
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ぴろず