#P5297. [北京省选集训2019] 完美塔防
[北京省选集训2019] 完美塔防
Description
The game board is an grid. Each cell may contain one of the following objects:
- Type A turret: shoots lasers in both up and down directions at the same time, represented by
|. - Type B turret: shoots lasers in both left and right directions at the same time, represented by
-. - Empty cell: a laser passes through and keeps moving in the same direction, represented by
.. - Obstacle: when a laser reaches it, the laser disappears, represented by
#. - Main mirror: when a laser reaches it, it changes direction according to the laws of physics and continues moving, represented by
\. - Secondary mirror: when a laser reaches it, it changes direction according to the laws of physics and continues moving, represented by
/.
Note that lasers can pass through each other, but if a laser goes out of the grid boundary, it also disappears.
Xiao N is a perfectionist player. He wants every empty cell to be hit by at least one laser, but he must not let any laser hit his own turrets and damage them.
Xiao N can change any number of Type A turrets into Type B turrets, and can also change any number of Type B turrets into Type A turrets.
Can you tell whether he can achieve his goal through these modifications?
Input Format
The first line contains a positive integer , the number of test cases.
For each test case, the first line contains two positive integers .
The next lines each contain a string of length , describing the board.
Output Format
For each test case, if there is no solution, output one line IMPOSSIBLE. Otherwise, output one line POSSIBLE, then output the modified board.
If there are multiple solutions, output any one.
3
1 3
-.-
3 4
#.##
#--#
####
4 3
.|.
-//
.-.
#\/
IMPOSSIBLE
POSSIBLE
#.##
#||#
####
POSSIBLE
.-.
|//
.-.
#\/
Hint
Constraints
For of the testdata:
- .
- .
Special Judge provided by @tiger2005.
Translated by ChatGPT 5
京公网安备 11011102002149号