Question: 12:48 icampus 3.0 icampus.ac.kr Problem #2. (Programming) Return (20 pts) We have a height map as a 2-dimensional array H(1 ...N, 1... M). We can
12:48 icampus 3.0 icampus.ac.kr Problem #2. (Programming) Return (20 pts) We have a height map as a 2-dimensional array H(1 ...N, 1... M). We can move from a location (i,j) to only 4 adjacent locations (i,j -1), (ij +1), (i-1,j), and (i1,j) by a single step However, we cannot directly move from (Lj) to (a, b) if lH[a,b]-H[i, > T. Moreover, each moving from (i,) to (a, b) has a cost based on heights. The cost is only 1 if Hli,jl 2 H[a, b] Otherwise, the cost is (Hi,j Ha, b)2. Suppose that we take a walk from a starting location (1,1) and return to (1,1). Compute the highest height (largest H) where we can visit within a given total cost S of the round trip. Input In the first line, two integers N(1 s N S 25) and M (1S Ms 25) are given where N and M are the number of rows and columns of the height map H, respectively. The following line contains two integers T(1 T 50) and S(1 S 1,000,000). After that, N M integer array H is given. Output You are required to output the highest height where we can reach. Sample input Sample output 18 74 1 2 34 09 105 0876 0 14 12 10 0 16 188 0246 Note that, your program can allocate up to 512MB memory and should produce the output within 3 seconds. You are asked to briefly describe your algorithm in the report and name your source code file "ID A3 Return.cpp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
