Codeforces Round 297 (Div. 2)
D
Arthur and Walls
Codeforces
2400
原题
← CE →
翻译中…

Finally it is a day when Arthur has enough money for buying an apartment. He found a great option close to the center of the city with a nice price.

翻译中…

Plan of the apartment found by Arthur looks like a rectangle $*n* × *m*$ consisting of squares of size $1 × 1$. Each of those squares contains either a wall (such square is denoted by a symbol "*" on the plan) or a free space (such square is denoted on the plan by a symbol ".").

翻译中…

Room in an apartment is a maximal connected area consisting of free squares. Squares are considered adjacent if they share a common side.

翻译中…

The old Arthur dream is to live in an apartment where all rooms are rectangles. He asks you to calculate minimum number of walls you need to remove in order to achieve this goal. After removing a wall from a square it becomes a free square. While removing the walls it is possible that some rooms unite into a single one.

翻译中…

Input

翻译中…

The first line of the input contains two integers $*n*, *m*$ ($1 ≤ *n*, *m* ≤ 2000$) denoting the size of the Arthur apartments.

翻译中…

Following $*n*$ lines each contain $*m*$ symbols — the plan of the apartment.

翻译中…

If the cell is denoted by a symbol "*" then it contains a wall.

翻译中…

If the cell is denoted by a symbol "." then it this cell is free from walls and also this cell is contained in some of the rooms.

翻译中…

Output

翻译中…

Output $*n*$ rows each consisting of $*m*$ symbols that show how the Arthur apartment plan should look like after deleting the minimum number of walls in order to make each room (maximum connected area free from walls) be a rectangle.

翻译中…

If there are several possible answers, output any of them.

翻译中…

样例

Input #1
5 5
.*.*.
*****
.*.*.
*****
.*.*.
Output #1
.*.*.
*****
.*.*.
*****
.*.*.
InputCopy OutputCopy
Input #2
6 7
***.*.*
..*.*.*
*.*.*.*
*.*.*.*
..*...*
*******
Output #2
***...*
..*...*
..*...*
..*...*
..*...*
*******
InputCopy OutputCopy
Input #3
4 5
.....
.....
..***
..*..
Output #3
.....
.....
.....
.....
InputCopy OutputCopy
题目信息
题号
525D
时间限制
2 s
内存限制
512 MB
标签
构造
数据结构
图论
贪心
最短路

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