作業1是排中秋節那天公佈,第一題不曉得正確解法為何.
感覺有點困難,亂解,答案有誤嗎? 數字是抄自圓周率,答案不曉得對不對?
INPUT
10 10 10 6
3,14,-15,-9,-2,-6,5,3,5,-8
9,7,-9,-3,2,-3,8,4,-6,2
6,4,-3,-3,-8,-3,2,-7,9,5
0,-2,-8,-8,4,19,7,16,9,3
9,9,-3,7,5,-10,5,-8,-20,-9
7,4,-9,4,-4,-5,9,-2,-3,0
7,8,16,4,0,-6,-2,8,6,20
-8,9,9,8,-6,-2,8,0,-3,-4
-8,-2,5,3,-4,-2,11,7,0,-6
7,9,-8,2,-14,-8,0,-8,6,5
Output
128
23
Move 1 0
Move 2 0
Move 3 0
Move 4 0
Move 5 0
Move 6 0
Move 6 1
Move 6 2
Move 7 2
Move 7 3
Move 7 4
Move 7 5
Move 7 6
Move 8 6
Move 8 7
Move 8 8
Move 9 8
Jump 3 5
Move 3 6
Move 3 7
Move 3 8
Jump 6 9
Jump 9 9
Robot
Time Limit: 1 s
Mem Limit: 1048576 KB
Problem Description
Robert is a farmer. He has a farm, denoted by an n×m grids. Each grid has unlimited nuts and each nut has its "sweetness". Moreover, all nuts in the same grid have the same sweetness.
Robert would like to harvest some nuts, so he tries to control his robot named "Robot1003" to complete this mission. In the beginning, Robot1003 is at the top-left corner of the farm. Robert can only control Robot1003 to move to the right or the down to the current grid directly. When Robot1003 is in a grid, it must take one nut in that grid. Besides, Robert has k space machines. Once he consumes one space machine, he can make Robot1003 jump to any grid in the farm, including the current grid. However,
whenever using a space machine, every nut in every grid will decrease its sweetness by a constant c. Robert can stop this process only when Robot1003 reaches the bottom-right corner of the farm. Robert hopes that the total sweetness harvested by Robot1003 can be as much as possible. Please help Robert calculate the optimal way to control Robot1003 to maximize the total sweetness.
Input
The first line contains four integers n,m,k,c (1?n,m?500, 0?k?10, 1?c?109), denoting the number of row and column of the farm, the number of space machine Robert has, and the decreasing value when using a space machine.
In the next n lines, the i-th contains m integers. The j-th integer aij (?109?aij?109) represents the initial sweetness of nuts in the grid (i,j). (0?i<n,0?j<m).
Output
The first line of output contains an integer, denoting the maximal sweetness that can be harvested by Robot1003.
The second line contains an integer s, denoting the number of movement throughout the process. In the following next s lines, i-th line represents the i-th step of movement. If Robert use the time machine at the i-th movement, output "Jump". Otherwise, output "Move". After that, output two integers, representing the coordinate Robot1003 currently at after the i-th movement.
If there are multiple ways to control Robot1003 to maximize the total sweetness, you can output any one of them.