#CCC24J5. Harvest Waterloo
Harvest Waterloo
In the farming simulation Harvest Waterloo, pumpkins and hay bales are arranged in a rectangular field. The farmer starts on a pumpkin and can move up, down, left, or right, but cannot move diagonally, through hay bales, or outside the field.
Pumpkin values:
S: $1M: $5L: $10
Input Format
- Integer
R: number of rows - Integer
C: number of columns Rlines: field description usingS,M,L,*- Integer
A: starting row (0-indexed) - Integer
B: starting column (0-indexed)
Output Format Output the total pumpkin value the farmer can collect.
Sample Input
6
6
**LMLS
S*LMMS
S*SMSM
******
LLM*MS
SSL*SS
5
1
Sample Output
37
Explanation: reachable pumpkins → 2 small, 1 medium, 3 large = 37.