题目描述
Problem Description
There is a park divided into $ H $ sections in the north-south direction and $ W $ sections in the east-west direction, forming a grid of $H \times W$ sections. The section at the $ i $-th position from the north and the $ j $-th position from the west is denoted as section $ (i,j) $.
The elevation of section $ (i,j) $ is $ A_{i,j} $, and all sections have different elevations.
Spring water emerges from section $ (s_x,s_y) $.
Water flows to only one of the adjacent sections (east, west, north, or south) with a lower elevation than the current section (limited to those within the park). If all adjacent sections have higher elevations than the current section, the water stays in the current section and does not flow out to the surrounding sections.
Output the sections where water flows, including section $ (s_x,s_y) $, as W, and the others as ..
Input Format
The input is given from the standard input in the following format:
$ H $ $ W $ $ s_x $ $ s_y $ $ A_{1,1} $ $ ... $ $ A_{1,W} $ $ : $ $ A_{H,1} $ $ ... $ $ A_{H,W} $
Output Format
Output $ H $ strings of length $ W $ where the $ j $-th character of the $ i $-th string is W if water flows to section $ (i,j) $, and . otherwise.
Sample Input and Output
Sample Input #1
3 3
2 2
5 6 7
3 9 2
4 8 1
Sample Output #1
...
.WW
..W
Sample Input #2
3 3
2 2
3 8 2
6 5 7
1 9 4
Sample Output #2
...
.W.
...
Sample Input #3
4 4
2 1
16 10 9 7
13 11 12 6
14 15 4 5
1 2 3 8
Sample Output #3
.WWW
WW.W
..WW
WWW.
Notes/Hints
Constraints
- $1 \leq H,W \leq 500$
- $1 \leq s_x \leq H$
- $1 \leq s_y \leq W$
- $1 \leq A_{i,j} \leq H \times W$
- $A_{i,j} \neq A_{x,y}$ for $(i,j) \neq (x,y)$
Sample Explanation 1
- Spring water emerges from section $ (2,2) $.
- Among the adjacent sections to section $ (2,2) $ with lower elevations, the section with the lowest elevation is section $ (2,3) $, so the water flows to section $ (2,3) $.
- Among the adjacent sections to section $ (2,3) $ with lower elevations, the section with the lowest elevation is section $ (3,3) $, so the water flows to section $ (3,3) $.
- All adjacent sections to section $ (3,3) $ have higher elevations than section $ (3,3) $, so the water stays in section $ (3,3) $.
Sample Explanation 2
Pay attention to the case where the water stays in section $ (s_x,s_y) $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分