409663: GYM103677 A Raiser Mais

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Raiser Maistime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

In a spark of creative genius, Remi has constructed a powerful laser that shoots out a beam of highly concentrated raisin energy. Many interested parties, including government contractors, have already reached out about the raisin laser, but first Remi wants to make sure that her 'raiser' is fully operational and functions just like a regular laser. To test the raiser, Remi has constructed a grid maze or 'mais' with deflective mirrors to see if she can place the raiser somewhere in the mais and have its beam reflect off of the angled mirrors and eventually hit a target receptor. Help Remi figure out all of the places where she could place the raiser such that its beam will eventually hit the receptor if it behaves like a regular laser.

Input

The first line of input contains two integers, $$$M$$$ and $$$N$$$ ($$$3 \leq M, N \leq 300$$$), denoting the number of rows and columns in the mais grid.

$$$M$$$ lines follow, each consisting of $$$N$$$ characters representing cells in the mais. A # denotes a beam-absorbing wall which will end an incoming raiser beam's propagation—these will always surround the outside of the grid and not appear anywhere else. A capital letter O denotes the single receptor cell in the outer wall where Remi wants the raiser beam to terminate. A . denotes an empty space in the mais which the raiser beam can freely propagate across. Lastly, / or \ denote deflecting mirrors which will redirect an incoming raiser beam depending on the direction (up, down, right, or left) in which the beam is coming from.

Output

Print out the mais grid from the input except mark each of the cells with an @ where Remi could place the raiser emitter facing in some direction to eventually target the receptor cell.

ExampleInput
7 15
###############
#/.....\/....\#
#\...\.....\..#
#/.../.\/.././#
#\............#
#..../.\...\..O
###############
Output
###############
#/@@@@@\/@@@@\#
#\@@@\.@@..\.@#
#/@@@/.\/../@/#
#\@@@@@@@@@@@@#
#..../.\...\@@O
###############

加入题单

算法标签: