Golf courseProblem code: F1 |
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.
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 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.
Output
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.
Example
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)
| Author: | admin |
| Date Added: | 10-07-2009 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments

Fetching successful submissions

If two different squares have the same highest elevation, we choose the square with the higher elevation in the top-left corner?
you need to consider the highest elevation point(s) for each k*ksquare.
don't need to compare the squares
I keep getting an NZEC error when running my python solution. How is this possible, since python is a scripting language and not expected to return zero anyway?
@Jacinda You might be having problems with I/O
@admin I think that's the case, but I don't know how to diagnose it because it's the same type of input and output statements used in the sample solutions for python (raw_input() and print,). Is there a better way for me to diagnose this?
excuse mee!!!But the memory limit is 50000Bytes and the value of m and n can be 500..It will take me atleast 250000Bytes to take the input...
It is source code limit not memory limit
@Jacinda @admin I am also getting the NZEC error when running my python solution. How do I determine what's going wrong?
You need to check whether your I/O is working fine. If you still keep facing this issue, contact us on admin@codechef.com
could adding an extra space at end of each output line of numbers or and extra newline at end of output lead to wrong answer?
No, it won't.
Time-limit is very strict. I think for worst case the input file size exceeds 10 MB.
No, the input file size is nowhere close to 10 MB.
i m asking an absurd ques but can anyone give me the link for the gcc compiler to download for c/c lang.
Regards
70M
http://blog.codechef.com/2009/06/29/frequently-asked-questions/ Please read the FAQ
Hi,
I am trying to submit since yesterday, but continuously getting runtime (NZEC) error. I tried various test cases in my local system and it gives correct output. Please help me out...
I'm getting SIGSEGV but on my system its working fine.
Can you please tell me how much memory we can use?