codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1669G.md (1661B)


      1 Source: https://codeforces.com/problemset/problem/1669/G
      2 
      3 G. Fall Down
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 There is a grid with $n$ rows and $m$ columns, and three types of cells:
     22 
     23 * An empty cell, denoted with '.'.
     24 * A stone, denoted with '*'.
     25 * An obstacle, denoted with the lowercase Latin letter 'o'.
     26 
     27 All stones fall down until they meet the floor (the bottom row), an obstacle, or other stone which is already immovable. (In other words, all the stones just fall down as long as they can fall.)
     28 
     29 Simulate the process. What does the resulting grid look like?
     30 
     31 Input
     32 
     33 The input consists of multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 100$) — the number of test cases. The description of the test cases follows.
     34 
     35 The first line of each test case contains two integers $n$ and $m$ ($1 \leq n, m \leq 50$) — the number of rows and the number of columns in the grid, respectively.
     36 
     37 Then $n$ lines follow, each containing $m$ characters. Each of these characters is either '.', '*', or 'o' — an empty cell, a stone, or an obstacle, respectively.
     38 
     39 Output
     40 
     41 For each test case, output a grid with $n$ rows and $m$ columns, showing the result of the process.
     42 
     43 You don't need to output a new line after each test, it is in the samples just for clarity.
     44 
     45 Example
     46 
     47 Input
     48 
     49 ```
     50 3
     51 6 10
     52 .*.*....*.
     53 .*.......*
     54 ...o....o.
     55 .*.*....*.
     56 ..........
     57 .o......o*
     58 2 9
     59 ...***ooo
     60 .*o.*o.*o
     61 5 5
     62 *****
     63 *....
     64 *****
     65 ....*
     66 *****
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 ..........
     73 ...*....*.
     74 .*.o....o.
     75 .*........
     76 .*......**
     77 .o.*....o*
     78 
     79 ....**ooo
     80 .*o**o.*o
     81 
     82 .....
     83 *...*
     84 *****
     85 *****
     86 *****
     87 ```