Golf course Puzzle
Practice
0 (0 votes)
Basic programming
Easy
Problem
52% Success 55 Attempts 20 Points 5s Time Limit 256MB Memory 1024 KB Max Code

A ABC company wants to invest into building a golf course. They could choose the land which is of rectangular shape of size AxB. The rectangle area is divided into AxB 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(A,B)). Thus, there are (A-K+1)(B-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.

Input

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 A, B, K (1 <= A, B <= 10, 1 <= K <= min(A,B) ).
  • There are A lines follow. Each line contains B nonnegative integers not exceeding 50. Each integer represents the elevation of a cell.

There is a blank line after each test case.

Output

For each test case, in the first line print "Case d:" where d is the number of the test case. Then print A-K+1 lines and in each line print B-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.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
OpenOpenMediumCombinatoricsCombinatorics basicsBasics of CombinatoricsMathematicsOpenMath
Points:20
3 votes
Tags:
ImplementationProbability and StatisticsProbability distributionEasyMathematicsapprovedProbability distribution
Points:30
6 votes
Tags:
AlgorithmsString AlgorithmsBasics of String ManipulationStringData Structures
Editorial

No editorial available for this problem.