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
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » DreamSpark 2 » AppleTrees

AppleTrees

Problem code: DPC201

  • All Submissions

All submissions for this problem are available.

 Apple Trees

 

Apple trees in a garden form a rectangular grid. A group of monkeys lives on these

trees. Not more than one monkey lives in each tree. A monkey feels happy to believe that it is

the lord of all apple trees it views from the top of the tree it lives in. However, as the trees are

of different heights a monkey can view trees that are not obstructed from its view by other

trees. A monkey that views the maximum number T of trees is a lord of lords. The undisputed

monarch is the lord of lords that lives in the highest tree. In case two or more lord of lords

have the claim to be the monarch then monarchy is disputed.

Assume that the ground of the garden is plane; vertical straight lines represent trees;

trees are at a distance of unity row-wise or column-wise; and the height of each tree is an

integer in the unit of the distance. A tree of height zero in a position indicates absence of a

tree on that position. Visibility of a tree R from the top of a tree P depends on heights and

locations of P, R and other trees. A tree R is invisible from the top of a tree P if and only if

there exists a visible tree Q that lies on the vertical plane containing P and R and is located

between P and R so that the top of R is either on or below, the line joining tops of P and Q.

Write a program to locate the undisputed monarch, given heights of all trees.

Input

The input may contain multiple test cases.

For each test case, the first line gives two integers m and n representing respectively

the total number of rows and columns of trees in the garden. Each of the next m lines

contains n integers representing heights of trees in a row. The jth integer in the ith row

represents the height of the tree in ith row and jth column of the garden. Assume that the

garden contains no more than 200 trees.

The input terminates with an input 0 as the first input for a test case.

 

Output

For each test case output three integers r, c and T in one line. Integers r and c

represent the location of the undisputed monarch, where r is the row number and c is the

column number of the tree on which the monarch lives. In case monarchy is disputed, both r

and c are zero. The integer T represents the total number of trees visible to a lord of lords.

Sample Input

3 3

1 2 3

4 5 6

7 0 9

3 4

4 4 4 4

4 4 4 4

4 4 4 4

1 10

5 3 2 1 6 4 2 8 7 1

0

Sample Output

2 2 7

0 0 10

1 5 6


Author: rushikesh30
Date Added: 9-03-2010
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, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

Please register at

MSP_bitmesra @ 13 Mar 2010 07:51 PM

Please register at http://bit.ly/DSPPC2_Register to claim prizes and certificates.

The CodeChef Rankings are not

MSP_bitmesra @ 15 Mar 2010 02:36 AM

The CodeChef Rankings are not accepted Directly. Some Mal-Practices have been observed and Strict action would be taken.

Well, this was very unlucky

alok @ 16 Mar 2010 02:30 AM

Well, this was very unlucky and sad.Obviously many participants knew the test cases used for submissions and this was most unfair contest. Please take action againts those who've just printed the sample output and Dreamsparks team should ATLEAST ban them, how could you allow someone from admin to participate when he know about testing standards ?

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 algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm 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 programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were 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 challenges 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 coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

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. You can also host a coding contest for your institute on CodeChef, organize an algorithm event 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