海洋

海岛问题

与世无争的帅哥 提交于 2019-12-30 00:04:33
问题描述: You will be given a map of Soteholm as an N×M grid. Each square in the grid has a side length of 1 km and is either water or land. Your goal is to compute the total length of sea coast of all islands. Sea coast is all borders between land and sea, and sea is any water connected to an edge of the map only through water. Two squares are connected if they share an edge. You may assume that the map is surrounded by sea. Lakes and islands in lakes are not contributing to the sea coast. Figure 1: Gray squares are land and white squares are water. The thick black line is the sea coast. This