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

建议使用的浏览器:

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

1453:City hall

题目描述
Because of its age, the City Hall has suffered damage to one of its walls. A matrix with M rows and N columns represents the encoded image of that wall, where 1 represents an intact wall and 0 represents a damaged wall (like in Figure-1).

               1110000111
               1100001111
               1000000011
               1111101111
               1110000111

                   Figure-1

To repair the wall, the workers will place some blocks vertically into the damaged area. They can use blocks with a fixed width of 1 and different heights of {1,2, ..., M}.

For a given image of the City Hallˇs wall, your task is to determine how many blocks of different heights are needed to fill in the damaged area of the wall, and to use the least amount of blocks.
输入解释
There is only one test case. The case starts with a line containing two integers M and N (1 <= M, N <= 200). Each of the following M lines contains a string with length of N, which consists of ¨1〃s and/or ¨0〃s. These M lines represent the wall.
输出解释
You should output how many blocks of different heights are needed. Use separate lines of the following format:

k Ck

where k劇{1,2, ..., M} means the height of the block, and Ck means the amount of blocks of height k that are needed. You should not output the lines where Ck = 0. The order of lines is in the ascending order of k.
输入样例
5 10
1110000111
1100001111
1000000011
1111101111
1110000111
输出样例
1 7
2 1
3 2
5 1
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-1453

最后修改于 2020-10-25T22:45:06+00:00 由爬虫自动更新

共提交 111

通过率 64.86%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/32768K(Java/Others)