Frequencies on a board P66664


Statement
 

pdf   zip

thehtml

We have a board with m rows and n columns. In each board cell there is a digit (0, ..., 9). Write a program that computes the frequency of each digit in each of the n columns of the board. The number of rows of a board can be very large.

Input

The input is a series of cases. Each case consists of two integers greater than zero m and n denoting, respectively, the number of rows and columns on the board, followed by a row-by-row description of the board’s digits.

Output

For each case in the input, a frequency table. The table has ten rows, respectively representing the digits 0, .., 9 and n columns. The table value in row d column j should be the frequency of digit d in column j of the corresponding input board. A blank line appears after the frequency table.

Public test cases
  • Input

    6 3
    0 1 0
    6 8 5
    4 2 9
    0 1 5
    5 9 5
    0 9 1
    
    5 4
    0 1 0 0
    2 3 0 0
    4 5 0 0
    6 7 0 0
    8 9 5 5
    
    1 5
    0 2 4 6 8
    
    3 1
    7
    8 
    9
    

    Output

    3 0 1
    0 2 1
    0 1 0
    0 0 0
    1 0 0
    1 0 3
    1 0 0
    0 0 0
    0 1 0
    0 2 1
    
    1 0 4 4
    0 1 0 0
    1 0 0 0
    0 1 0 0
    1 0 0 0
    0 1 1 1
    1 0 0 0
    0 1 0 0
    1 0 0 0
    0 1 0 0
    
    1 0 0 0 0
    0 0 0 0 0
    0 1 0 0 0
    0 0 0 0 0
    0 0 1 0 0
    0 0 0 0 0
    0 0 0 1 0
    0 0 0 0 0
    0 0 0 0 1
    0 0 0 0 0
    
    0
    0
    0
    0
    0
    0
    0
    1
    1
    1
    
    
  • Information
    Author
    Pro1
    Language
    English
    Translator
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    C++ Python
    User solutions
    Python