AtCoder Beginner Contest 233
翻译中…
Problem Statement
翻译中…
There is a $N \times N$ grid, with blocks on some squares.
The grid is described by $N$ strings $S_1,S_2,\dots,S_N$, as follows.
翻译中…
- If the
$j$-th character of$S_i$is#, there is a block on the square at the$i$-th row from the top and$j$-th column from the left. - If the
$j$-th character of$S_i$is., there is not a block on the square at the$i$-th row from the top and$j$-th column from the left.
翻译中…
Takahashi can do the operation below zero or more times.
翻译中…
- First, choose an integer
$D$between$1$and$N$(inclusive), and a$D \times D$subsquare within the grid. - Then, consume
$D$stamina points to destroy all blocks within the subsquare.
翻译中…
Find the minimum number of stamina points needed to destroy all the blocks.
翻译中…
Constraints
翻译中…
$N$is an integer.$1 \le N \le 50$$S_i$consists of#and..$|S_i|=N$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
S_1
S_2
\vdots
S_N
翻译中…
Output
翻译中…
Print the answer as an integer.
翻译中…
样例
Input #1
5
##...
.##..
#.#..
.....
....#
Output #1
4
By choosing the subsquares below, Takahashi will consume $4$ stamina points, which is optimal.
- The $3 \times 3$ subsquare whose top-left square is at the $1$-st row from the top and $1$-st column from the left.
- The $1 \times 1$ subsquare whose top-left square is at the $5$-th row from the top and $5$-th column from the left.
Input #2
3
...
...
...
Output #2
0
There may be no block on the grid.
Input #3
21
.....................
.....................
...#.#...............
....#.............#..
...#.#...........#.#.
..................#..
.....................
.....................
.....................
..........#.....#....
......#..###.........
........#####..#.....
.......#######.......
.....#..#####........
.......#######.......
......#########......
.......#######..#....
......#########......
..#..###########.....
.........###.........
.........###.........
Output #3
19
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。