## CCO '19 P2 - Sirtet

View as PDF

Points: 20 (partial)
Time limit: 1.0s
Memory limit: 1G

Author:
Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

In a fancy new zero-person video game, Sirtet, the game is a rectangular grid with rows and columns. Before the game begins, some grid cells are blank (denoted as .) and others are filled (denoted as #). The filled squares represent a set of objects, and the filled squares that are adjacent (horizontally or vertically) should be considered to be part of the same rigid object. For example, this initial grid:

..#.
##.#
.##.
#...
#...

has four objects, shown below:

 ##  # # #
## #

When the game begins, the objects fall straight down the grid, all at the same speed. Each object continues to fall straight down until it either touches the bottom row, or has some part of it land directly on top of another object, at which point it stops. What will be the final state of the grid?

#### Input Specification

The first line contains two space-separated positive integers and .

The following lines contain characters each, describing the initial state of the grid. If the -th column of the -th row of the grid contains a block, the corresponding character in the input will be a #, otherwise it will be a . character.

For 10 of the 25 available marks, .

For an additional 6 of the 25 available marks, .

#### Output Specification

Output lines contain characters each, describing the final state of the grid. If the -th column of the -th row of the grid contains a block, the corresponding character in the input will be a #, otherwise it will be a . character.

#### Sample Input

5 4
..#.
##.#
.##.
#...
#...

#### Output for Sample Input

....
....
###.
###.
#..#