Problem E
Board Coloring
One day you were visiting a museum where you saw a modern
piece of art that shows a grid of
You think that the art is so simple so that even you can
reproduce it yourself. After getting home, you get yourself a
grid board with exactly
You soon realize that the art seems to be simple but is not so easy to reproduce. Actually, you are not even sure about whether it is possible to reproduce the art with the aforementioned procedure. You eventually decide to make it a ProgNova question and ask some smart people for help.
Input
The first line contains two integers
Output
Output “YES” if it is possible to reproduce the art piece, or “NO” otherwise.
Sample Input 1 | Sample Output 1 |
---|---|
4 5 WRRRG WRRRG WRRRG WBBBB |
YES |
Sample Input 2 | Sample Output 2 |
---|---|
3 4 WWRR WRRR WRRR |
NO |
Sample Input 3 | Sample Output 3 |
---|---|
3 3 WWW WWW WWW |
YES |