Give you a n * m lawn, ask if only light a fire, burning of lawn, most from the n * m in any one place the grass began to ignition, fire can only to the up and down or so passed, where no grass can not burn,
[input format]
The input consists of multiple test cases, each test case of the first line contains two integers n and m, (1 & lt;=n, m<=100), the number of rows and columns respectively 01 matrix,
Followed by n lines, each line containing m integers 0 or 1, 1 is for lawn, 0 means what also have no, the adjacent two integers separated with a space between two measuring
Separated by a blank line between test cases, and finally a test case, an empty line after the last line contains two integers 0, said input end,
Output format []
Each test case corresponds to a line output, containing an integer, only light a fire to burn up the lawn,
[sample input]
5 6
1 1 0 0 0 1
1 1 0 0 1
1 0 0 0 0 1
1 1 0 0 0 1
1 1 1 1 0 0
0 0
[sample output]
7
CodePudding user response:
Please note code can be are givenCodePudding user response:
Graphics seed filling algorithm