#abc233g. G - Strongest Takahashi
G - Strongest Takahashi
Score : points
问题描述
存在一个 的网格,其中某些格子上放置有方块。
该网格由 个字符串 描述,如下所示:
- 如果 的第 个字符是
#
,则在从顶部数第 行、从左边数第 列的格子上有一个方块。 - 如果 的第 个字符是
.
, 则在从顶部数第 行、从左边数第 列的格子上没有方块。
Takahashi 可以执行以下操作零次或多次:
- 首先,选择一个整数 ,其取值范围在 到 (包含)之间,并在网格内选取一个 的子方格。
- 然后,消耗 点体力值来摧毁子方格内的所有方块。
请找出摧毁所有方块所需的最小体力值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a grid, with blocks on some squares.
The grid is described by strings , as follows.
- If the -th character of is
#
, there is a block on the square at the -th row from the top and -th column from the left. - If the -th character of is
.
, there is not a block on the square at the -th row from the top and -th column from the left.
Takahashi can do the operation below zero or more times.
- First, choose an integer between and (inclusive), and a subsquare within the grid.
- Then, consume stamina points to destroy all blocks within the subsquare.
Find the minimum number of stamina points needed to destroy all the blocks.
Constraints
- is an integer.
- consists of
#
and.
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
5
##...
.##..
#.#..
.....
....#
Sample Output 1
4
By choosing the subsquares below, Takahashi will consume stamina points, which is optimal.
- The subsquare whose top-left square is at the -st row from the top and -st column from the left.
- The subsquare whose top-left square is at the -th row from the top and -th column from the left.
Sample Input 2
3
...
...
...
Sample Output 2
0
There may be no block on the grid.
Sample Input 3
21
.....................
.....................
...#.#...............
....#.............#..
...#.#...........#.#.
..................#..
.....................
.....................
.....................
..........#.....#....
......#..###.........
........#####..#.....
.......#######.......
.....#..#####........
.......#######.......
......#########......
.......#######..#....
......#########......
..#..###########.....
.........###.........
.........###.........
Sample Output 3
19
update @ 2024/3/10 10:09:30