Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Has to be done in java AP Institute 2011 Mowing Uncle Mo mows rectangular lawns that are L feet long and W feet wide. The

Has to be done in javaimage text in transcribed

AP Institute 2011 Mowing Uncle Mo mows rectangular lawns that are L feet long and W feet wide. The lawns are divided into 1 foot by 1 foot squares, and some of these squares have trees growing within them (shown as black circles in the figure below) W Columns Uncut Lawn Cut Lawn (shaded portion) Mo has a 3 x 3 foot square lawn mower that can only move parallel to the edges of the lawn (vertical or horizontal). It must remain entirely within the rectangular lawn at all times and can never overlap a square containing a tree. The lawn mower cannot be rotated and cannot be picked up and moved over a tree You are to write a program to determine which squares of the lawn can be cut ("reached") by the lawn mower (the shaded region in the right portion of the above figure assuming the mower' intial position was row 5, column 6) Inputs The first line of the input contains the number of lawns to be cut. This is followed by one data set for each lawn. The first line of a data set contains four positive integers, the length and width, L and W, followed by row and column number of the initial position of the center of the lawn mower (row 0, column 0 is the upper left square of the lawn). Each of the next L lines contains W marker characters, each of which corresponds to a square on the lawn. The marker character T means that there is a tree on the square and the marker character. means no tree. To aid readability, each marker character is preceded by a single space. (You may assume that length and width are at most 40.) AP Institute 2011 Mowing Uncle Mo mows rectangular lawns that are L feet long and W feet wide. The lawns are divided into 1 foot by 1 foot squares, and some of these squares have trees growing within them (shown as black circles in the figure below) W Columns Uncut Lawn Cut Lawn (shaded portion) Mo has a 3 x 3 foot square lawn mower that can only move parallel to the edges of the lawn (vertical or horizontal). It must remain entirely within the rectangular lawn at all times and can never overlap a square containing a tree. The lawn mower cannot be rotated and cannot be picked up and moved over a tree You are to write a program to determine which squares of the lawn can be cut ("reached") by the lawn mower (the shaded region in the right portion of the above figure assuming the mower' intial position was row 5, column 6) Inputs The first line of the input contains the number of lawns to be cut. This is followed by one data set for each lawn. The first line of a data set contains four positive integers, the length and width, L and W, followed by row and column number of the initial position of the center of the lawn mower (row 0, column 0 is the upper left square of the lawn). Each of the next L lines contains W marker characters, each of which corresponds to a square on the lawn. The marker character T means that there is a tree on the square and the marker character. means no tree. To aid readability, each marker character is preceded by a single space. (You may assume that length and width are at most 40.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago