#P11078. 「FSLOI Round I」迷雾
「FSLOI Round I」迷雾
Description
The Misty Forest can be represented as a grid of size , where cells with character X have dense fog, while cells with character . are empty.
Denote the cell in the -th row from the top and the -th column from the left as .
A fog constant is given.
FL_sleake made moves. The -th move consists of one character and two integers and . Specifically:
- If is
U, take steps upwards. - If is
D, take steps downwards. - If is
L, take steps to the left. - If is
R, take steps to the right.
In each step, he will go by exactly one cell towards the given direction. However, if he will move outside of the forest after the step, he just stays in the current cell instead.
If FL_sleake stays in a cell with fog after he performs the -th move, he will perform an operation on . If , No operations will be performed.
An operation on a character is replacing it with another character representing the opposite direction of . That is:
- If is
U, replace it withD. - If is
D, replace it withU. - If is
L, replace it withR. - If is
R, replace it withL.
Initially FL_sleake is at , please find his position after the moves.
Recall that is the same for all moves.
Input Format
The first line of the input contains four integers .
In the following lines, each line contains a string of length , representing the Misty Forest.
In the following lines, the -th line contains one character , and two integers and , representing the -th move.
Output Format
Output a single line containing two integers and , representing that FL_sleake's position after the moves is .
3 3 4 1
..X
.XX
XXX
D 1 2
R 1 2
D 2 0
L 1 0
1 3
10 10 8 2
XX.XX.X...
XXX..XXX.X
XXX.X.XXXX
XXXXXXX.X.
.XX...XX.X
.XXX.X.X.X
...XXX.XXX
XX...XX...
X..XX....X
XXXXX...XX
U 2 1
L 1 3
R 3 1
L 1 2
D 2 1
R 5 1
L 4 0
D 3 0
1 10
Hint
Example Explanation
In the first example, FL_sleake's position at the beginning and after each move is as follow:
$(1,1) \rightarrow (2,1) \rightarrow (2,2)\rightarrow (1,2) \rightarrow (1,3)$
The sequence at the beginning and after each move is as follow:
$\lbrace \texttt{D,R,D,L} \rbrace \rightarrow \lbrace \texttt{D,R,D,L} \rbrace \rightarrow \lbrace \texttt{D,R,U,R} \rbrace \rightarrow \lbrace \texttt{D,R,U,R} \rbrace \rightarrow \lbrace \texttt{D,R,U,R} \rbrace$
Constraints
Subtasks are used in this problem.
For all tests, it is guaranteed that:
| Subtask Id | Score | Special Property |
|---|---|---|
| - |
京公网安备 11011102002149号