CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » August 2009 (Contest VI) » Golf course

Golf course

Problem code: F1

  • All Submissions

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


  • Submit

Comments

  • Login or Register to post a comment.

xiaowuc1 @ 2 Aug 2009 12:47 AM

If two different squares have the same highest elevation, we choose the square with the higher elevation in the top-left corner?

atulbansal128 @ 2 Aug 2009 01:48 AM

you need to consider the highest elevation point(s) for each k*ksquare.
don't need to compare the squares

jacinda @ 2 Aug 2009 07:39 AM

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?

admin 2 @ 2 Aug 2009 08:25 AM

@Jacinda You might be having problems with I/O

jacinda @ 2 Aug 2009 08:50 AM

@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?

gauravsc @ 2 Aug 2009 02:29 PM

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...

atulbansal128 @ 2 Aug 2009 06:16 PM

It is source code limit not memory limit

mattlong @ 4 Aug 2009 10:32 AM

@Jacinda @admin I am also getting the NZEC error when running my python solution. How do I determine what's going wrong?

admin 2 @ 4 Aug 2009 06:47 PM

You need to check whether your I/O is working fine. If you still keep facing this issue, contact us on admin@codechef.com

dejavu @ 4 Aug 2009 11:36 PM

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?

admin 2 @ 5 Aug 2009 12:51 AM

No, it won't.

pr0ton @ 5 Aug 2009 06:43 PM

Time-limit is very strict. I think for worst case the input file size exceeds 10 MB.

admin 2 @ 5 Aug 2009 07:02 PM

No, the input file size is nowhere close to 10 MB.

t0m @ 7 Aug 2009 08:53 PM

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

admin 2 @ 7 Aug 2009 09:01 PM

http://blog.codechef.com/2009/06/29/frequently-asked-questions/ Please read the FAQ

kalaiselvant @ 9 Aug 2009 07:28 PM

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...

vikash @ 11 Aug 2009 08:25 PM

I'm getting SIGSEGV but on my system its working fine.
Can you please tell me how much memory we can use?

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com