6_12 Oilfield (UVa572) < graph of Connected block dfs>

Source: Internet
Author: User

An oil company is responsible for the exploration of the oil content under a block of land, which is a moment-line, and is cut into many small pieces for the convenience of exploration. Then use the instrument to explore each small piece. A small piece of oil is called a pocket. If two pocket is connected, the two pocket is the same oil deposit. (The so-called connected definitions are the same as those in the mine game, please refer to sample input,sample output)
Your task is to find out how many different oil deposit the land contains.
Input
The input contains several sets of data, and the first row of each group of data has 2 integer m,n. M represents the number of columns in this plot, and N represents the number of rows in this plot. (1<=m,n<=100), the next M-line is the content of this piece of land exploration. ' @ ' stands for this small piece of oil, ' * ' on behalf of this small block contains no oil. M=0 N=0 represents the end of the input.
Output
The number of oil deposit output for each set of test data.

Sample input
1 1
*
3 5
*@*@*
**@**
*@*@*
1 8
@@****@*
5 5
****@
*@@*@
*@**@
@@@*@
@@**@
0 0

Sample Output
0
1
2
2

6_12 Oilfield (UVa572) < graph of Connected block dfs>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.