{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"The GeoSurvComp geologic survey company is responsible for detecting underground \noil deposits. GeoSurvComp works with one large rectangular region of land at a \ntime, and creates a grid that divides the land into numerous square plots. It \nthen analyzes each plot separately, using sensing equipment to determine whether \nor not the plot contains oil. A plot containing oil is called a pocket. If two \npockets are adjacent, then they are part of the same oil deposit. Oil deposits \ncan be quite large and may contain numerous pockets. Your job is to determine \nhow many different oil deposits are contained in a grid.\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eInput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eThe input file contains one or more grids. Each grid begins with a line containing \n m and n, the number of rows and columns in the grid, separated by a single space. \n If m \u003d 0 it signals the end of the input; otherwise 1 \u0026lt;\u003d m \u0026lt;\u003d 100 and \n 1 \u0026lt;\u003d n \u0026lt;\u003d 100. Following this are m lines of n characters each (not counting \n the end-of-line characters). Each character corresponds to one plot, and is \n either `*\u0027, representing the absence of oil, or `@\u0027, representing an oil pocket.\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eOutput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eFor each grid, output the number of distinct oil deposits. Two different pockets \n are part of the same oil deposit if they are adjacent horizontally, vertically, \n or diagonally. An oil deposit will not contain more than 100 pockets.\u003c/p\u003e\n\u003cp\u003e\u003cb\u003e\u003cbr\u003e\n Sample Input\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e1 1\u003cbr\u003e\n *\u003cbr\u003e\n 3 5\u003cbr\u003e\n *@*@*\u003cbr\u003e\n **@**\u003cbr\u003e\n *@*@*\u003cbr\u003e\n 1 8\u003cbr\u003e\n @@****@*\u003cbr\u003e\n 5 5 \u003cbr\u003e\n ****@\u003cbr\u003e\n *@@*@\u003cbr\u003e\n *@**@\u003cbr\u003e\n @@@*@\u003cbr\u003e\n @@**@\u003cbr\u003e\n 0 0 \u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Output\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e0\u003cbr\u003e\n 1\u003cbr\u003e\n 2\u003cbr\u003e\n 2\u003cbr\u003e\n\u003c/p\u003e\n"}}]}