Codeforces Round 375 (Div. 2)
D
Lakes in Berland
Codeforces
1600
原题
← CE →
翻译中…

The map of Berland is a rectangle of the size $*n* × *m*$, which consists of cells of size $1 × 1$. Each cell is either land or water. The map is surrounded by the ocean.

翻译中…

Lakes are the maximal regions of water cells, connected by sides, which are not connected with the ocean. Formally, lake is a set of water cells, such that it's possible to get from any cell of the set to any other without leaving the set and moving only to cells adjacent by the side, none of them is located on the border of the rectangle, and it's impossible to add one more water cell to the set such that it will be connected with any other cell.

翻译中…

You task is to fill up with the earth the minimum number of water cells so that there will be exactly $*k*$ lakes in Berland. Note that the initial number of lakes on the map is not less than $*k*$.

翻译中…

Input

翻译中…

The first line of the input contains three integers $*n*$, $*m*$ and $*k*$ ($1 ≤ *n*, *m* ≤ 50$, $0 ≤ *k* ≤ 50$) — the sizes of the map and the number of lakes which should be left on the map.

翻译中…

The next $*n*$ lines contain $*m*$ characters each — the description of the map. Each of the characters is either '.' (it means that the corresponding cell is water) or '*' (it means that the corresponding cell is land).

翻译中…

It is guaranteed that the map contain at least $*k*$ lakes.

翻译中…

Output

翻译中…

In the first line print the minimum number of cells which should be transformed from water to land.

翻译中…

In the next $*n*$ lines print $*m*$ symbols — the map after the changes. The format must strictly follow the format of the map in the input data (there is no need to print the size of the map). If there are several answers, print any of them.

翻译中…

It is guaranteed that the answer exists on the given data.

翻译中…

Note

翻译中…

In the first example there are only two lakes — the first consists of the cells $(2, 2)$ and $(2, 3)$, the second consists of the cell $(4, 3)$. It is profitable to cover the second lake because it is smaller. Pay attention that the area of water in the lower left corner is not a lake because this area share a border with the ocean.

翻译中…

样例

Input #1
5 4 1
****
*..*
****
**.*
..**
Output #1
1
****
*..*
****
****
..**
InputCopy OutputCopy
Input #2
3 3 0
***
*.*
***
Output #2
1
***
***
***
InputCopy OutputCopy
题目信息
题号
723D
时间限制
2 s
内存限制
256 MB
标签
DFS 及类似
并查集
图论
贪心
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。