CF1669G.Fall Down

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a grid with nn rows and mm columns, and three types of cells:

  • An empty cell, denoted with '.'.
  • A stone, denoted with '*'.
  • An obstacle, denoted with the lowercase Latin letter 'o'.

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.)

Simulate the process. What does the resulting grid look like?

输入格式

The input consists of multiple test cases. The first line contains an integer tt ( 1t1001 \leq t \leq 100 ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and mm ( 1n,m501 \leq n, m \leq 50 ) — the number of rows and the number of columns in the grid, respectively.

Then nn lines follow, each containing mm characters. Each of these characters is either '.', '*', or 'o' — an empty cell, a stone, or an obstacle, respectively.

输出格式

For each test case, output a grid with nn rows and mm columns, showing the result of the process.

You don't need to output a new line after each test, it is in the samples just for clarity.

输入输出样例

  • 输入#1

    3
    6 10
    .*.*....*.
    .*.......*
    ...o....o.
    .*.*....*.
    ..........
    .o......o*
    2 9
    ...***ooo
    .*o.*o.*o
    5 5
    *****
    *....
    *****
    ....*
    *****

    输出#1

    ..........
    ...*....*.
    .*.o....o.
    .*........
    .*......**
    .o.*....o*
    
    ....**ooo
    .*o**o.*o
    
    .....
    *...*
    *****
    *****
    *****
首页