Lakes in Berland

题意翻译

**【问题描述】** ldxxx已经填完了所有的坑,现在他要给土地浇水来保证幼苗的茁壮成长。然而他刚要浇水,就迎来了瓢泼大雨,由于土地渗透性不一,所以有的土地上存在积水,连在一起的积水就形成了一个小湖泊(只有四周被陆地完全包围的才算湖泊,只要和边界有交点就不算湖泊),这时cs告诉ldxxx说如果能将湖泊的数量缩小到一个值k的话,他的庄稼长得应该最茂盛。但是由于ldxxx很笨,不知道该怎么填,所以ldxxx把浇水的任务给了cs,由于这次是义务劳动,所以cs很懒,想填最少的水使得湖泊数量为k你需要告诉他把湖泊数降到**不大于k**至少需要填多少块,并且把填好后的土地积水情况给他打印出来。 注意:只有四周被陆地完全包围的才算湖泊,只要和边界有交点就不算湖泊。 题面翻译来自accoders **【输入格式】** 第一行三个用空格分离的正整数 n,m和k,代表土地的长和宽。 接下来 n 行,每行m个字符,*''代表陆地,'.'代表水。数据保证至少含有k个湖。 **【输出格式】** 输出共n+1行。 第一行一个正整数,表示把湖泊数降到k以下至少需要填多少块。 接下来n行每行m个字符,**''代表陆地,'.'代表水**。 注:输入和输出 每行的字符之间不含空格。 **【数据范围】** **1<=n,m<=50 0<=k<=50**

题目描述

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

输入输出格式

输入格式


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.

输出格式


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.

输入输出样例

输入样例 #1

5 4 1
****
*..*
****
**.*
..**

输出样例 #1

1
****
*..*
****
****
..**

输入样例 #2

3 3 0
***
*.*
***

输出样例 #2

1
***
***
***

说明

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.