当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3854:Another Brick in the Wall

题目描述
After years as a brick-layer, you've been called upon to analyze the instability of brick walls. The instability of a wall can be approximated by the maximum damage to a wall in case of taking one brick out. A brick will fall if all bricks that are directly underneath it are removed. Note that if the space underneath a brick is partially empty, it does not fall.
You are given the description of all bricks in a wall, and must determine the instability of the wall as described in the following sections.
输入解释
There are multiple test cases in the input. Each test case consists of a single line, "M N" (1 ≤ M, N ≤ 100) where M and N indicate the height and width (in units), respectively, of the input wall.

Each of the next M lines is a string of N digits which specifies a row in the wall. Each brick in a row is represented by a substring of the row (like s) such that every digit in s is the same, which is equal to the length of s too. For example, 333 and 22 are two bricks of length 3 and 2 respectively, but 111 specifies three bricks of length one. A 0 in a row means there is no brick in that place of wall. Note that the height of each brick is one. The input terminates with a line containing 0 0. You may assume that the input is correct. This means:
1) There is no brick such that the length of the brick does not conform to the digits in the brick (like 222 in the row 12221).
2) No brick can fall initially.
输出解释
For each test case, write a single line containing maximum sum of the bricks’ lengths that will fall if we take one brick out (including that brick).
输入样例
4 5
33322
22333
33322
22333
4 6
122333
444422
111111
333333
3 3
022
220
111
0 0
输出样例
5
8
4

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Tehran 2009

源链接: POJ-3854

最后修改于 2020-10-29T07:13:47+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536