CF377A.Maze

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Pavel loves grid mazes. A grid maze is an n×mn×m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.

Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any other one. Pavel doesn't like it when his maze has too little walls. He wants to turn exactly kk empty cells into walls so that all the remaining cells still formed a connected area. Help him.

输入格式

The first line contains three integers nn , mm , kk ( 1<=n,m<=5001<=n,m<=500 , 0<=k<s ), where nn and mm are the maze's height and width, correspondingly, kk is the number of walls Pavel wants to add and letter ss represents the number of empty cells in the original maze.

Each of the next nn lines contains mm characters. They describe the original maze. If a character on a line equals ".", then the corresponding cell is empty and if the character equals "#", then the cell is a wall.

输出格式

Print nn lines containing mm characters each: the new maze that fits Pavel's requirements. Mark the empty cells that you transformed into walls as "X", the other cells must be left without changes (that is, "." and "#").

It is guaranteed that a solution exists. If there are multiple solutions you can output any of them.

输入输出样例

  • 输入#1

    3 4 2
    #..#
    ..#.
    #...
    

    输出#1

    #.X#
    X.#.
    #...
    
  • 输入#2

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

    输出#2

    #XXX
    #X#.
    X#..
    ...#
    .#.#
    
首页