#P15188. [SWERC 2019] Pixels
[SWERC 2019] Pixels
题目描述
There are various ways to protect wildlife. One is to make posters that will inspire people, and that is the job of artists. Some of those people that need to be inspired are geeks, and that is why some artists focus on pixel art.
An artist prepared a pixel art drawing for depicting animals in black and white. These drawings should be displayed on a gigantic pixelated, rectangular screen, with rows (ordered from 0 to , from top to bottom) and columns (ordered from 0 to , from left to right): displaying drawings on such screens is your job.
When you initialize the screen, it displays only white pixels. Then, its pixels should be controlled individually by switches, and pressing the switch of a pixel ought to change the color of , either from black to white or from white to black. However, the screen has a defect: pressing the switch of the pixel also changes the color of those pixels that have an edge in common with , i.e., those pixels that are adjacent horizontally or vertically (but not diagonally). Yet, it might still be possible that, by adequately choosing which switches you press, even this defective screen can display the drawing you were handed.
Can you manage to display that drawing? If yes, which set of switches should you press?
Note
Note that the order in which switches are pressed is not important, and that it is never necessary to press twice the same switch. Thus, a solution can be fully described by the set of switches pressed. There might be several solutions, i.e., several adequate sets of switches. In that case, your output should just represent one such solution.
输入格式
- Line 1 contains two integers and , separated by spaces.
- For all such that , line contains symbols "B" or "W", separated by spaces: if the symbol (with ) is a "B", then the pixel that will be displayed on row and column should be black; otherwise, it should be a white pixel.
1 2
B W
IMPOSSIBLE
5 22
B B B W B W W W B W B B B W B B B B W B B B
B W W W B W W W B W B W W W B W W B W B W W
B B B W B W B W B W B B B W B B B B W B W W
W W B W B W B W B W B W W W B W B W W B W W
B B B W W B W B W W B B B W B W W B W B B B
A P P A P P A A P A A P P P A A P A P A P A
A P P A P A P P A P A P A A A A A P P P A A
A P P A P P A A A P P A A P P A A P A P A A
A A A A A A P P A P P P A A P A A P P P P A
A P A A A A P A P P P A P A P P A P P P A P
提示
Sample Explanation 1
Whenever you press a switch, the colors of both pixels changes. Hence, they always have the same color, and the drawing cannot be displayed.
Sample Explanation 2
You can indeed check that, if you press the switches associated to the red pixels of the left picture, you will obtain the picture depicted on the right.
:::align{center}
:::
Limits
- .