Blue Bridge Cup - Global Warming (BFS/DFS)

1. Description of the topic

You have a N x N pixel photo of   a sea area , "." means ocean, "#" means land, as follows:

.......
.##....
.##....
....##.
..####.
...###.
.......

  Among them, a piece of land connected together in the four directions of "up, down, left, and right" forms an island. For example, there are 2 islands in the picture above.

  Due to rising sea levels caused by global warming, scientists predict that in the next few decades, one pixel of the edge of the island will be submerged in sea water. Specifically, if a land pixel is adjacent to the ocean (there are oceans among the four adjacent pixels up, down, left, and right), it will be submerged.

  For example, the sea area in the picture above will look like this in the future:

.......
.......
.......
.......
....#..
.......
.......

  Do your calculations: How many islands in the photo will be completely submerged according to scientists' predictions.

enter description

  The first line contains a

Guess you like

Origin blog.csdn.net/qq_43753724/article/details/129869437