■ Title description
[Looking for the mine pile with the greatest value]
You are given a map consisting of '0' (empty land), '1' (silver mine), and '2' (gold mine). The
ore pile can only be formed by connecting adjacent gold or silver mines above, below, left, and right. Areas beyond the map can be considered open space.
Assume that the value of silver ore is 1 and the value of gold ore is 2. Please find the most valuable ore pile on the map and output the value of this ore pile.
Enter description
Map element information such as:
22220
00000
00000
11111
The maximum map range is 300*300
0<= map element<=2
Output description
The maximum value of the ore pile
Example 1 input and output examples are for debugging only, and the background judgment data generally does not contain examples.
enter
22220
00000
00000
01111
output
8
Sample description
Return public suffix: c
Python code implementation: