Given an m ✕ n matrix A, please calculate the k-by-k max-pooling of A.
Both m and n are multiples of k.
The computation of k-by-k max-pooling is to find the maximum for each k-by-k block of A.
For example, if k is 2 and A is
1 2 3 4 5 6
6 5 4 3 2 1
9 8 7 6 5 4
4 5 6 7 8 9
, then the output should be
6 4 6
9 7 9
because they are the maximal values of the partitions:
1 2|3 4|5 6
6 5|4 3|2 1
--------------
9 8|7 6|5 4
4 5|6 7|8 9
Note: This is a partial judge problem. We have already handled the input and output for you. All you have to do is to implement the function "max_pooling". You are allowed to define another function to support the max_pooling function. However, the downloaded partial judged file should strictly not be changed.
void max_pooling(int A[500][500], int H, int W, int k)
The first line contains three integers m, n, and k, representing the dimensions m, n of matrix A and the size of the block.
The next m lines are elements of the matrix [Aij], i = 0...(m-1) and j = 0...(n-1)
It is guaranteed that 1 ≤ m, n ≤ 500 and k is either 2 or 3
Notice that if k = 2, m and n can be divided by 2, and so on.
We have already handled the input for you.
Please print the result of k-by-k max-pooling.
We have already handled the output for you.