Mr. Gorilla, a muscular man, has gotten lost in a maze. The maze is a rectangle...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Mr. Gorilla, a muscular man, has gotten lost in a maze. The maze is a rectangle of n rows and m columns, and it consists of open spaces and walls. Mr. Gorilla starts at positions and he wants to go to position G. Both s and G are open spaces. Mr. Gorilla can move in four directions, up, down, left, and right. The time it takes to move is determined in this way: • If the position he's trying to move into is not a wall, it takes one second. • If the position he's trying to move into is a wall, he breaks down the wall because he is so strong and moves into the new space that was occupied by the wall before he broke it down. However, each wall he breaks down makes him more tired, so he must rest r seconds after breaking down each wall, where z is the total number of walls he has broken down prior to that wall. Moreover, it takes one more second to actually move into the new space. Mr. Gorilla is not good at working with his brain. Therefore, implement a program which calculates for Mr. Gorilla the minimum amount of time needed for him to move from position s to position G. The mission You are given a maze. Calculate the minimum amount of time needed for Mr. Gorilla to move from position s to position G. Implementation CLI Implement a command line application that receives standard input and writes the answer to its standard output. For details, see the "Command line application template" section at the bottom of the page. Input rules Your CLI program should receive standard input. ./ myApp The format of the standard input is as below: n m S1 Sn The conditions are as follows: 2 <n, m < 30, integer • S; is a string whose length is m o Consists of only s. G, s denotes the position Mr. Gorilla starts from 6 denotes the destination of Mr. Gorilla denotes an open space # denotes a wall s and G are always open spaces The following additional condition is satisfied for 30% of all test cases. • There are no walls # in the given maze Output rule Your CLI program should write the answer to its standard output. The format of the standard output is as below: Standard output answer On the 1st line, print the minimum time needed for Mr. Gorilla to move from position s to position G. Input & Output examples Example 1 Standard input ( 00_samplel.in ) 3 3 S## 林。 #. G Standard output 5 Let's call the position of the ith row and the jth column the point (i, j) (1 <isn,1<j<m). Mr. Gorilla can reach the destination in 5 seconds by moving in the following way: • At first Mr. Gorilla is at point (1, 1). He breaks down the wall at point (2, 1) and moves into the space. As he has broken no other walls yet, it takes 0 seconds to break this wall. It takes 1 second to move. He breaks down the wall at point (2, 2) and moves into the space. As he broke 1 wall previously, it takes 1 second to break this wall. It also takes 1 second to move. • He moves to point (2, 3). This takes 1 second. He moves to point (3, 3). This takes 1 second. • He reaches his destination. Example 2 Standard Input ( 00_sample2.in ) 3 3 S## ### .. G Standard Output 4 Mr. Gorilla starts at point (1, 1). • He breaks down the wall at point (2, 1) and moves into the space. As he has broken no walls previously to this wall, it takes 0 seconds to break this wall. It takes 1 second to move. • He moves to point (3, 1). It takes 1 second. • He moves to point (3, 2). It takes 1 second. • He moves to point (3, 3). It takes 1 second. He reaches his destination. Example 3 Standard Input ( 00_sample3.in ) 5 3 ... ..S ... .G. ... Standard Output 3 This test case satisfies the conditions of the simple test cases because the maze has no walls. • Mr. Gorilla starts at point (2, 3). • He moves to point (2, 2). This takes 1 second. He moves to point (3, 2). This takes 1 second. He moves to point (4, 2). This takes 1 second. He reaches his destination. There are other input & output examples defined in this file: test/basic_testcases.json You can use it as a reference while working on this exercise. Command line application template for C Implement CLI application by editing main.c. You may add new files to keep your code clean, if it is allowed in your challenge. How to get stdin lines You can use scanf, fget , etc. The template has sample code which using fget. You can modify that code as you like. How to output result How to output result You can use printf. printf ("argv[i]: %s\n", i, argv[i]); How to compile To compile, we are using clang gcc command. If you want to change compile option or etc, please edit makefile. Mr. Gorilla, a muscular man, has gotten lost in a maze. The maze is a rectangle of n rows and m columns, and it consists of open spaces and walls. Mr. Gorilla starts at positions and he wants to go to position G. Both s and G are open spaces. Mr. Gorilla can move in four directions, up, down, left, and right. The time it takes to move is determined in this way: • If the position he's trying to move into is not a wall, it takes one second. • If the position he's trying to move into is a wall, he breaks down the wall because he is so strong and moves into the new space that was occupied by the wall before he broke it down. However, each wall he breaks down makes him more tired, so he must rest r seconds after breaking down each wall, where z is the total number of walls he has broken down prior to that wall. Moreover, it takes one more second to actually move into the new space. Mr. Gorilla is not good at working with his brain. Therefore, implement a program which calculates for Mr. Gorilla the minimum amount of time needed for him to move from position s to position G. The mission You are given a maze. Calculate the minimum amount of time needed for Mr. Gorilla to move from position s to position G. Implementation CLI Implement a command line application that receives standard input and writes the answer to its standard output. For details, see the "Command line application template" section at the bottom of the page. Input rules Your CLI program should receive standard input. ./ myApp The format of the standard input is as below: n m S1 Sn The conditions are as follows: 2 <n, m < 30, integer • S; is a string whose length is m o Consists of only s. G, s denotes the position Mr. Gorilla starts from 6 denotes the destination of Mr. Gorilla denotes an open space # denotes a wall s and G are always open spaces The following additional condition is satisfied for 30% of all test cases. • There are no walls # in the given maze Output rule Your CLI program should write the answer to its standard output. The format of the standard output is as below: Standard output answer On the 1st line, print the minimum time needed for Mr. Gorilla to move from position s to position G. Input & Output examples Example 1 Standard input ( 00_samplel.in ) 3 3 S## 林。 #. G Standard output 5 Let's call the position of the ith row and the jth column the point (i, j) (1 <isn,1<j<m). Mr. Gorilla can reach the destination in 5 seconds by moving in the following way: • At first Mr. Gorilla is at point (1, 1). He breaks down the wall at point (2, 1) and moves into the space. As he has broken no other walls yet, it takes 0 seconds to break this wall. It takes 1 second to move. He breaks down the wall at point (2, 2) and moves into the space. As he broke 1 wall previously, it takes 1 second to break this wall. It also takes 1 second to move. • He moves to point (2, 3). This takes 1 second. He moves to point (3, 3). This takes 1 second. • He reaches his destination. Example 2 Standard Input ( 00_sample2.in ) 3 3 S## ### .. G Standard Output 4 Mr. Gorilla starts at point (1, 1). • He breaks down the wall at point (2, 1) and moves into the space. As he has broken no walls previously to this wall, it takes 0 seconds to break this wall. It takes 1 second to move. • He moves to point (3, 1). It takes 1 second. • He moves to point (3, 2). It takes 1 second. • He moves to point (3, 3). It takes 1 second. He reaches his destination. Example 3 Standard Input ( 00_sample3.in ) 5 3 ... ..S ... .G. ... Standard Output 3 This test case satisfies the conditions of the simple test cases because the maze has no walls. • Mr. Gorilla starts at point (2, 3). • He moves to point (2, 2). This takes 1 second. He moves to point (3, 2). This takes 1 second. He moves to point (4, 2). This takes 1 second. He reaches his destination. There are other input & output examples defined in this file: test/basic_testcases.json You can use it as a reference while working on this exercise. Command line application template for C Implement CLI application by editing main.c. You may add new files to keep your code clean, if it is allowed in your challenge. How to get stdin lines You can use scanf, fget , etc. The template has sample code which using fget. You can modify that code as you like. How to output result How to output result You can use printf. printf ("argv[i]: %s\n", i, argv[i]); How to compile To compile, we are using clang gcc command. If you want to change compile option or etc, please edit makefile.
Expert Answer:
Answer rating: 100% (QA)
Here i am using a small logic that is first i have to fond the ... View the full answer
Related Book For
Physics
ISBN: 978-0077339685
2nd edition
Authors: Alan Giambattista, Betty Richardson, Robert Richardson
Posted Date:
Students also viewed these algorithms questions
-
Need help with C programming. Write code to do allowing you to store these smaller floating point numbers in a 32-bit integer. INPUT: you will read in a program and call your functions to implement...
-
I need help with code for a LED cyclone light game.
-
JW's Lock & Key had the following transactions in December. Dec. 1 Paid December's rent, check & 6267, $2.000. 2 Paid annual premiums on property and casualty insurance policies, check 6288, $3,600 3...
-
The Sales Discounts account is a contra account to which of the following accounts? Cost of Goods Sold Sales Returns and Allowances Purchases Discounts Sales Revenue
-
Consider a cogeneration power plant modified with regeneration. Steam enters the turbine at 9 MPa and 400°C and expands to a pressure of 1.6 MPa. At this pressure, 35 percent of the steam is...
-
What brand development strategy is Coca-Cola undertaking? Coca-Cola launched Coca-Cola Plus in a limited market in Japan last year and now plans to launch it nationwide in that country. Coca-Cola...
-
Let total market demand for labor be represented by ED = 1,200 30w where ED is total employment and w is the hourly wage. Suppose 750 workers supply their labor to the market perfectly...
-
The Miramar Company is going to introduce one of three new products: a widget, a hummer, or a nimnot. The market conditions (favorable, stable, or unfavorable) will determine the profit or loss the...
-
The Conrad-Demarest Model describes the conditions that the authors feel are necessary for an empire, as well as the factors that can lead to its downfall. 1.) How well do each of these empires fit...
-
Suppose an investment project costs $100,000 to start in period 0, and we know of the dividends it will return with certainty. The project returns dividends of $0 in period 0, $20,000 in period 1,...
-
The Whitworth quick return motion mechanism has the driving crank AC=150 mm long. The distance between fixed centres CD= 100 mm. The line of stroke of the ram passes through the centre of rotation of...
-
Provide an overview over techniques for taking advantage of scratch pad memories!
-
Provide an example demonstrating priority inversion for a system comprising three jobs!
-
How could flash memory have an influence on the design of real-time databases?
-
Which components do FPGAs comprise? Which of these are used to implement Boolean functions? How are FPGAs configured? Are FPGAs energy-efficient? Which kind of applications are FPGAs good for?
-
Use the following news clip to work Problems Calculate the slope of the relationship in Problem 4 between 3,308 and 4,134 theaters. Problem 4 Draw a graph of the relationship between the revenue per...
-
Scenario Planning in a Rapidly changing Global Marketing Environment: Three events took place between 2001 and 2003 which changed the world. One was the attack on the World Trade Centre in 2001, the...
-
Why can wastewater treatment requirements in Hawaii be less stringent than those in most locations on the U.S. mainland?
-
In a reciprocating saw, a Scotch yoke converts the rotation of the motor into the back-and-forth motion of the blade. The Scotch yoke is a mechanical device used to convert oscillatory motion to...
-
An RC filter is shown. The filter resistance R is variable between 180 and 2200 and the filter capacitance is C = 0.086 F. At what frequency is the output amplitude equal to 1/ 2 times the input...
-
(a) Show that it was valid to ignore the gravitational force in Problem 97. In problem 97 A negatively charged particle of mass 5.00 1019 kg is moving with a speed of 35.0 m/s when it enters the...
-
The overall process of creating a capital budget proposal has a lot of similarities to writing a business plan for a start-up company. Describe three aspects of the similarities between a budget...
-
There are three general categories of capital budget scenarios: replacement, expansion, and investment in a NewCo. Describe the overall decision-making context for each. How do they draw on similar...
-
In analysis, some focus seems to be on the need for NPV equations to be applied to projects that are mutually exclusive. But in practice we find that the lines are blurred in capital budgeting....
Study smarter with the SolutionInn App