F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

City hall

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 497    Accepted Submission(s): 261


Problem Description
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.
 

Input
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.
 

Output
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.
 

Sample Input
5 10 1110000111 1100001111 1000000011 1111101111 1110000111
 

Sample Output
1 7 2 1 3 2 5 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:31:43, Gzip enabled