{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e\r\nh1,h2,h3,h4,h5,h6{margin-bottom:0;}div.textBG p{margin: 0 0 0.0001pt;}\u003c/style\u003e\r\n\u003ccenter\u003e\r\n\t\u003cp\u003e\r\n\t\t\u003cbr /\u003e\r\n\t\t\u0026nbsp;\u003c/p\u003e\r\n\t\u003ctable bgcolor\u003d\"#0060F0\"\u003e\r\n\t\t\u003ctbody\u003e\r\n\t\t\t\u003ctr\u003e\r\n\t\t\t\t\u003ctd\u003e\r\n\t\t\t\t\t\u003ch1\u003e\r\n\t\t\t\t\t\t\u003cspan style\u003d\"background-color: rgb(255, 255, 255);\"\u003eThe Mine\u003c/span\u003e\u003cb\u003e\u003cfont color\u003d\"#C0FFFF\" size\u003d\"5\"\u003e\u0026nbsp;\u0026nbsp;\u003c/font\u003e\u003c/b\u003e\u003c/h1\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\u003c/tr\u003e\r\n\t\t\u003c/tbody\u003e\r\n\t\u003c/table\u003e\r\n\u003c/center\u003e\r\n\u003cp\u003e\r\n\tThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyzes each plot separately, using sensing equipment to determine whether or not the plot contains oil.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tA plot containing oil is called a pocket. If two pockets are adjacent, then they are part of the same oil deposit. Oil deposits can be quite large and may contain numerous pockets. Your job is to determine how many different oil deposits are contained in a grid.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca href\u003d\"\" name\u003d\"SECTION0001001000000000000000\"\u003e Input\u003c/a\u003e\u0026nbsp;\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tThe input file contains one or more grids. Each grid begins with a line containing \u003ci\u003em\u003c/i\u003e and \u003ci\u003en\u003c/i\u003e, the number of rows and columns in the grid, separated by a single space. If \u003ci\u003em\u003c/i\u003e \u003d 0 it signals the end of the input; otherwise \u003c!-- MATH: $1 \\le m \\le 100$ --\u003e\u003cimg align\u003d\"MIDDLE\" alt\u003d\"$1 \\le m \\le 100$\" border\u003d\"0\" height\u003d\"30\" src\u003d\"http://uva.onlinejudge.org/external/5/572img1.gif\" width\u003d\"101\" /\u003e and \u003c!-- MATH: $1 \\le n \\le 100$ --\u003e\u003cimg align\u003d\"MIDDLE\" alt\u003d\"$1 \\le n \\le 100$\" border\u003d\"0\" height\u003d\"30\" src\u003d\"http://uva.onlinejudge.org/external/5/572img2.gif\" width\u003d\"96\" /\u003e. Following this are \u003ci\u003em\u003c/i\u003e lines of \u003ci\u003en\u003c/i\u003e characters each (not counting the end-of-line characters). Each character corresponds to one plot, and is either ` \u003ctt\u003e*\u003c/tt\u003e\u0026#39;, representing the absence of oil, or ` \u003ctt\u003e@\u003c/tt\u003e\u0026#39;, representing an oil pocket.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca href\u003d\"\" name\u003d\"SECTION0001002000000000000000\"\u003e Output\u003c/a\u003e\u0026nbsp;\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tFor each grid, output the number of distinct oil deposits. Two different pockets are part of the same oil deposit if they are adjacent horizontally, vertically, or diagonally. An oil deposit will not contain more than 100 pockets.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca href\u003d\"\" name\u003d\"SECTION0001003000000000000000\"\u003e Sample Input\u003c/a\u003e\u0026nbsp;\u003c/font\u003e\u003c/h2\u003e\r\n\u003cpre\u003e\r\n1 1\r\n*\r\n3 5\r\n*@*@*\r\n**@**\r\n*@*@*\r\n1 8\r\n@@****@*\r\n5 5\r\n****@\r\n*@@*@\r\n*@**@\r\n@@@*@\r\n@@**@\r\n0 0\r\n\u003c/pre\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca href\u003d\"\" name\u003d\"SECTION0001004000000000000000\"\u003e Sample Output\u003c/a\u003e\u0026nbsp;\u003c/font\u003e\u003c/h2\u003e\r\n\u003cpre\u003e\r\n0\r\n1\r\n2\r\n2\r\n\u003c/pre\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003chr /\u003e\r\n\u003caddress\u003e\r\n\t\u003ci\u003eMiguel A. Revilla\u003c/i\u003e\u003cbr /\u003e\r\n\t\u003ci\u003e1998-03-10\u003c/i\u003e\u003c/address\u003e\r\n\u003clink href\u003d\"http://uva.onlinejudge.org/external/5/htmlatex.css\" rel\u003d\"STYLESHEET\" /\u003e"}}]}