Codeforces Round 576 (Div. 1)
D
Rectangle Painting 1
Codeforces
2300
原题
← CE →
翻译中…

There is a square grid of size $n \times n$. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs $\max(h, w)$ to color a rectangle of size $h \times w$. You are to make all cells white for minimum total cost.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \leq n \leq 50$) — the size of the square grid.

翻译中…

Each of the next $n$ lines contains a string of length $n$, consisting of characters '.' and '#'. The $j$-th character of the $i$-th line is '#' if the cell with coordinates $(i, j)$ is black, otherwise it is white.

翻译中…

Output

翻译中…

Print a single integer — the minimum total cost to paint all cells in white.

翻译中…

Note

翻译中…

The examples and some of optimal solutions are shown on the pictures below.

翻译中…

image

翻译中…

样例

Input #1
3
###
#.#
###
Output #1
3
InputCopy OutputCopy
Input #2
3
...
...
...
Output #2
0
InputCopy OutputCopy
Input #3
4
#...
....
....
#...
Output #3
2
InputCopy OutputCopy
Input #4
5
#...#
.#.#.
.....
.#...
#....
Output #4
5
InputCopy OutputCopy
题目信息
题号
1198D
时间限制
1 s
内存限制
256 MB
标签
动态规划

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