Canadian Computing Competition: 2024 Stage 1, Junior #5
There is a wildly popular new harvest simulation game called Harvest Waterloo. The game is played on a rectangular pumpkin patch which contains bales of hay and pumpkins of different sizes. To begin the game, a farmer is placed at the location of a pumpkin.
The farmer harvests all pumpkins they can reach by moving left, right, up, and down throughout the patch. The farmer cannot move diagonally. The farmer can also not move through a bale of hay nor move outside of the patch.
Your job is to determine the total value of all the pumpkins harvested by the farmer. A small pumpkin is worth
Input Specification
The first line of input is an integer
The second line of input is an integer
The next S
for a small pumpkin, M
for a medium pumpkin, L
for a large pumpkin, or *
for a bale of hay.
The next line of input is an integer
The following table shows how the available 15 marks are distributed:
Marks | Description | Bound |
---|---|---|
1 | The patch is small and there are no bales of hay. | |
4 | The patch is small and the bales of hay divide the entire patch into rectangular areas. | |
5 | The patch is small and the bales of hay can be anywhere. | |
5 | The patch is large and the bales of hay can be anywhere. |
Output Specification
Output the integer,
Sample Input 1
6
6
**LMLS
S*LMMS
S*SMSM
******
LLM*MS
SSL*SS
5
1
Output for Sample Input 1
37
Explanation of Output for Sample Input 1
Starting at row
Sample Input 2
6
6
**LMLS
S*LMMS
S*SMSM
***SLL
LLM*MS
SSL*SS
2
4
Output for Sample Input 2
88
Explanation of Output for Sample Input 2
Starting at row
Comments
remember if ur using python to not forget about sys.setrecursionlimit(x) you will get IR error if u dont
or use bfs
how big do you have to set it
set it to 10^5 because the worst case is no haybales and r*c = 100000, in which case does 10^5 recursions. (note: maybe set it to 10^5 + 3 to prevent RecursionError because it works for me)
just set it to a gigantic number till it doesn't give one. sys.setrecursionlimit(10^7)
happy early birthday