1 / 14
文档名称:

Graphs算法竞赛入门经典刘汝佳.doc

格式:doc   大小:95KB   页数:14页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

Graphs算法竞赛入门经典刘汝佳.doc

上传人:mh900965 2018/4/15 文件大小:95 KB

下载得到文件列表

Graphs算法竞赛入门经典刘汝佳.doc

相关文档

文档介绍

文档介绍:The p geologic pany is responsible for detecting underground oil deposits. p 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.
A 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.
Input 
The input file contains one or more grids. Each grid begins with a line containingm and n, the number of rows and columns in the grid, separated by a single space. If m = 0 it signals the end of the input; otherwise  and . Following this are m lines of n characters each (not counting the end-of-line characters). Each character corresponds to one plot, and is either `*', representing the absence of oil, or `@', representing an oil pocket.
Output 
For 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.
Sample Input 
1 1
*
3 5
*@*@*
**@**
*@*@*
1 8
@@****@*
5 5
****@
*@@*@
*@**@
@@@*@
@@**@
0 0
Sample Output 
0
1
2
2
657 - The die is cast
InterGames is a high-tech pany that specializes in developing technology that allows users to play games over the . A market analysis has alerted them to the fact that games of chance are pretty popular among their potential customers. Be it Monopoly, ludo or backgammon, most of these games involve throwing dice at some stage of the game.
Of course, it would be unreasonable if players were allowed to throw their dice and then enter the result into puter, since cheating would be way to easy. So, instead, InterGames has decided to supply their users with a ca