All submissions for this problem are available.
A company wants to invest into building a golf course. They could choose the land to build the course from a rectangle area of size MxN. The rectangle area is divided into MxN cells. They measured the elevation of each cell and recorded it into an integer number.
The company decided that the golf course should be a KxK square (K ≤ min(M,N)). Thus, there are (M-K+1)(N-K+1) possible KxK squares that can be used to build the golf course. For each such square, the company wants to know the highest elevation of a cell inside the square. They also need to know how many cells that have such highest elevations.
Write a program that help the company do the above task.
The first line contains t, the number of test cases (about 10). Then t test cases follow. Each test case has the following form:
- The first line contains three integers M, N, K (1 ≤ M, N ≤ 500, 1 ≤ K ≤ min(M,N) ).
- There are M lines follow. Each line contains N nonnegative integers not exceeding 10000. Each integer represents the elevation of a cell.
There is a blank line after each test case.
For each test case, in the first line print "Case d:" where d is the number of the test case. Then print M-K+1 lines and in each line print N-K+1 entries. Successive entries should be separated by spaces. The entry in the ith line and the jth column has the following form:
- The first number is the highest elevation of a cell in the KxK square whose top left corner is (i,j).
- If there is more than one cell in the square that has the highest elevation, print (c), where c is the number of cells inside the square that have the highest elevation.
Print a blank line after each test case.
Input: 2 3 3 2 5 5 5 5 5 5 5 5 5 3 3 2 4 2 1 3 5 7 2 8 8 Output: Case 1: 5(4) 5(4) 5(4) 5(4) Case 2: 5 7 8 8(2)
|Time Limit:||0.14 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, TCL, SQL, kotlin, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.