Problem D
Fountain
Languages
en
sv
Consider a grid consisting of
-
If a water cell is directly above an air cell then the air cell turns into water in the next second.
-
If a water cell is directly above a stone cell then any air cells directly left or right of the water cell turn into water in the next second.
After some number of seconds, the water will have stopped spreading. Show how the grid looks when that happens. You can assume that all cells outside of the grid behave as air cells; for instance, if a water cell is at the bottommost row then its water will not spread to the sides.
Input
The first line consists of two integers
Each of the following
Output
Print
Sample Input 1 | Sample Output 1 |
---|---|
5 7 ...V... ....... ....... ...#... ..###.. |
...V... ...V... ..VVV.. .VV#VV. .V###V. |
Sample Input 2 | Sample Output 2 |
---|---|
12 14 ....V...V..... .............. .............. .............. ...#########.. .......#...... .......#.#.... .......#####.. ........###... ........#.#... ........#.#... ############## |
....V...V..... ....V...V..... ....V...V..... ..VVVVVVVVVVV. ..V#########V. ..V....#....V. ..V....#.#..V. ..V....#####V. ..V.....###.V. ..V.....#.#.V. VVVVVVVV#.#VVV ############## |