In this question, we want to shoot the ball from a certain coordinate in D direction and determine the final position of the ball
The ball will go in the given direction until it leaves the map or collides with a wall. In the latter case, the ball will change its direction based on its original direction and the wall's arrangement, namely:
/
: Change direction to Down
\
: Change direction to Up
/
: Change direction to Up
\
: Change direction to Down
/
: Change direction to Right
\
: Change direction to Left
/
: Change direction to Left
\
: Change direction to Right
For example in the sample input:
However, the ball can also stuck in the map forever.
The first line will be H, W, and D, representing the Height, Width of the map, and Direction
The next line will be HxW map, containing either '/', '\', '.', and 'S'
1 <= H, W <= 100
D is a string, the possibilites are "Left", "Right", "Up", and "Down"
Print the last coordinate before the ball leaves the border map (outside of the array) with format row and column, separated by a space.
If it is not possible to go out from the array, print "Stuck QQ"
Don't forget the new line character after the end of the output.