Hdu 1241 Oil Deposits
// There is a problem when writing input in c ++
# Include
# Include
# Include
# Include
/* The map array is used to hold the n of characters. m increases the scope and increases the access permission. dir facilitates the breadth-first search, because eight directions need to be searched, this is the most convenient */char map [101] [101]; int n, m; int dir [8] [2] = {-1,-1 }, {0,-1}, {1,-1 }}; int main () {void breadthFirstSearch (int x, int y); bool isWithinMap (int x, int y); while (scanf ("% d", & m, & n )! = EOF, n + m) {/* m is a row indicator n is a column indicator */getchar (); for (int I = 0; I
= M | y <0 | y> = n) {return false;} return true ;}
Oil Deposits Petroleum Reserves
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 18046 Accepted Submission (s): 10399
Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp geological survey company is responsible for detecting reserves of underground oil resources.
GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. each time GeoSurvComp works in a large rectangular area, it creates a grid to divide the land into many square flags.
It then analyzes each plot separately, using sensing equipment to determine whether or not the plot contains oil. then analyze each well and use sensing devices to determine whether the well contains oil.
A plot containing oil is called a pocket. an oil well is called an oilfield.
If two pockets are adjacent, then they are part of the same oil deposit.
If the two fields are adjacent and they are adjacent. Oil deposits can be quite large and may contain in numerous pockets. The Oil resources may be large and may contain many Oil wells.
Your job is to determine how many different oil deposits are contained in a grid.
Your job is to determine how many different fields are contained in a grid.
Input The input file contains one or more grids. The Input file contains one or more grids.
Each grid begins with a line containing m and n, the number of rows and columns in the grid, separated by a single space. the first row of each grid is m and n, indicating that the grid is m rows and n columns. Each number is separated by a space. If m = 0 it signals the end of the input; otherwise 1 <= m <= 100 and 1 <= n <= 100. if m = 0, the input end is 1 <= m <= 100 and 1 <= n <= 100. Following this are m lines of n characters each (not counting the end-of-line characters ). each line has n characters (excluding carriage return characters); Each character corresponds to one plot, and is either '*', representing the absence of oil, or '@', representing an oil pocket.
Each character corresponds to an oil field. "*" indicates that there is no oil well, and "@" indicates an oil well.
Output For each grid, output the number of distinct oil deposits. For each grid, Output the number of different petroleum resources.
Two different pockets are part of the same oil deposit for different wells, if they are adjacent horizontally, vertically, or diagonally. if the horizontal, vertical, and oblique angles are adjacent, the two wells are an oilfield.
An oil deposit will not contain in more than 100 pockets.
An oilfield can contain up to 100 oil wells.
Sample Input
1 1*3 5*@*@***@***@*@*1 8@@****@*5 5 ****@*@@*@*@**@@@@*@@@**@0 0
Sample Output
0122
Source Mid-Central USA 1997