Description: Topic description
In order to enhance the ability of kindergarten children count, Tiger s teacher gave the job of a family game. He let the Tigers get an empty chess set, randomly put some pawn in some grid (black or white), if a box and it s one of the down, left, and right box have pawn of the same color, the two grid connect. During this period, the Tigers continue to Statistics Total number of connected blocks.
The following figure is a 5 × 9 board, where "space,"* "represents the black pawn," @ ", said the white pawn. There are four connected piece.
.........
..** .. @ ..
.** @ @ @ @.
..* @ ..* ..
.........
Brothers and Big Tiger, he is thinking while watching, if the board is the N × N, let M a pawn how to use the computer to solve this problem?
Input requirements
1 lines of two integers: N, M, (1 ≤ N ≤ 500,1 ≤ M ≤ N × N).
Next M lines, each line of three positive integers: C and the X, Y (0 ≤ C ≤ 1,1 ≤ X, Y, ≤ N), respectively, turn into the color of the pawn (0 white
To Search:
File list (Check if you may need any files):
BLOCKS.PAS
P152-5连通块.html