# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13260 | Nappa's Attack |
|
13588 | Find the maximum in the sliding window |
|
Description
Nappa is on his way to destroy a city for some fun, however on his way there, he was stopped by an army shooting at him so Nappa decided to destroy them for fun too.
Before he destroyed them, he noticed that the men in the army form a pattern. Each group forms a triangular shape as follows:
The strongest one is at the center and is protected by layers of weaker soldiers and those soldiers are protected by even weaker soldiers.
There are many sizes and Nappa wants to see every pattern there could be so he must write a program in his scouter to show him every possibility of this pattern.
Input
The input will contain a single integer N, the strongest soldier at the center.
0<N<1000
Output
The output will require you to print the entire traingle pattern with the strongest soldier at the center having the N power level.
There need not be space between numbers but there should be a new line at the end of every line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given a 2D matrix whose size is N * N, and a 2D sliding window whose size is M * M. Our goal is to find the maximum in each sliding window. The sliding window will start from the left-top corner, in each iteration, the sliding window will move 1 unit only, and it will stop after going through the whole matrix.
For example, given a 2D matrix
and a 2 * 2 sliding window,
then the output will be
Input
The first line is the matrix size N, where 3 ≤ N ≤ 15.
The second line is the sliding window size M, where 2 ≤ M < N.
Then the following N*N numbers are the elements of this matrix, the value of these elements is ranged from 1 to 10000.
Output
The new 2D matrix.
Use “%5d” to print each element and do not print any additional space!
You need to print a newline character at the end of each line. ('\n')