| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 313 | 260 | 219 | 84.556% |
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 s days can be represented with a matrix with r rows and s columns, consisting only of characters . and #. The character # in the i-th column represents the value of NFP on the i-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 s days.
Noa wants to determine the insecurity for n NFPs, whose values are represented by matrices with r rows and s columns.
Help him determine the insecurity of each of the n NFPs.
The first line contains integers n, r and s (1 ≤ n ≤ 20, 2 ≤ r, s ≤ 50), the number of NFPs, and the number of rows and colums of the matrices.
n matrices follows, one below another, each with r rows and s columns, representing NFP values. Each column consists only of characters ., except for exactly one character #.
Print n lines. In the i-th of n lines print the insecurity od the i-th NFP.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 5 | r = s = 2 |
| 2 | 15 | n = 1 |
| 3 | 30 | No additional constraints. |
4 2 2 ## .. .. ## #. .# .# #.
0 0 1 1
1 5 8 .....#.# ...#..#. ..#.#... .#...... #.......
4
2 3 3 ... ##. ..# .#. #.. ..#
1 2
Note: For clarity’s sake, in the examples there are blank lines between matrices. In the test cases there will not be 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 5 − 1 = 4.