Desni klik
Time limit1sMemory limit1024 MB
For each matrix, read the value of each column from the position of its single # and print the difference between the maximum and minimum values.
- Level
Easy1 of 10
- Topics
- Implementation, String
- Solved
- No attempts yet
Statement
NFP is the future!, this is something all Noa's friends can expect him to say when finance topics come up.
NFP is one of the cryptocurrencies. The value of NFP over the course of days can be represented with a matrix with rows and columns, consisting only of characters . and #. The character # in the -th column represents the value of NFP on the -th day, with the value being the number of the row, counted bottom-up.
....##.
#..#...
.##....
......#
The value of NFP from the second example over the course of 7 days was: 3, 2, 2, 3, 4, 4, 1. The insecurity of this NFP is 3.
The insecurity of NFP is defined as the difference between the maximum and minimum value it achieves over the course of days.
Noa wants to determine the insecurity for NFPs, whose values are represented by matrices with rows and columns.
Help him determine the insecurity of each of the NFPs.
Input
The first line contains integers , and (, ), the number of NFPs, and the number of rows and columns of the matrices.
matrices follow, one below another, each with rows and columns, representing NFP values. Each column consists only of characters ., except for exactly one character #.
Output
Print lines. In the -th of the lines, print the insecurity of the -th NFP.
Hint
For clarity's sake, the examples have blank lines between matrices. The test cases have no blank lines between matrices.
Clarification of the first example: The values of the first and the second NFP do not change over the days, so their insecurities are equal to 0. The value of the third NFP decreases by 1 on the second day, so the insecurity is equal to 1. The value of the fourth NFP increases by 1 on the second day, so the insecurity is equal to 1.
Clarification of the second example: The maximum value NFP has is 5 (on days 6 and 8), and the minimum value is 1 (on day 1). Therefore, the insecurity is equal to .