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
-
An object on Pluto that follows p(t) = -0.325t2 - 20.0t + 500.0. The following equations give the positions as functions of time of objects tossed from towers in various exotic solar system...
-
Amelie, a retired physician, is 66 years old. Determine her standard deduction under the following scenarios. a. Amelie is married to Roget, age 52, and they file married joint. b. Amelie is single....
-
Discuss the privacy and confidentiality issues of HIV-positive patients.
-
Institutionally Related Foundations. Compass State University Foundation (CSUF) was incorporated as a not-for-profit organization to support a public university in its fund-raising efforts and the...
-
Multiplication of signed operands, which generate a double-length product in the 2's-complement 100 11 MULTIPLICAND (-13) 0 10 1 1 MULTIPLIER (+11) number system. The general strategy is the...
-
What is the process of allocating the cost of a plant asset over its useful life called?
-
Considering the sign up fee and monthly membership fee for a gym the equation c=30m+25 can be used to represent the total cost of a gym membership for m months what is the amount of the sign up fee
-
Why is it important that you identify the outcome you want from a presentation before you begin composing it?
-
What features of a Facebook post can increase audience response and interaction?
-
Name two goals that bad-news messages must simultaneously accomplish.
-
In what key ways is a persuasive customer claim different from other kinds of requests, such as requests for information, a favor, or a donation? Why are different persuasive techniques necessary?
-
Motivating your audience is particularly important when you are asking them to do something that is difficult or that they are resistant to doing. Imagine that you are writing a persuasive email,...
-
in c++ please Digicup This program simulates interactions with a cup object for getting a drink, refilling a drink, emptying a drink, and drinking from it. Output All of the output statements...
-
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 PCAOB ended the self-regulation of the external auditing profession. True/false
-
The National Crisis Inquiry Report (2011) concluded that the financial crisis was unavoidable. True/false
-
External auditors collect consulting fees from the same clients they perform independent audits for, which allows good and close relationship with the clients. True/false
Study smarter with the SolutionInn App