Go SubProgram. When the white child enclose the sunspots, the sunspots will be taken away.
InAlgorithmIdea: a two-dimensional array qipan [] [] is used to represent the chess piece. 0 indicates null, 1 indicates white, and 2 indicates sunspots; A two-dimensional array flag [] [] is used to represent the flag of row I. The flag [] [] is initialized as 0 for the pawns in column J. From left to right, from top to bottom, when qipan [I] [J] = 2, if the front and back of qipan are both white, then the flag [I] [J] = Flag [I] [J] + 1; if it has a white child on the left and a black child on the top, then flag [I] [J] = Flag [I] [J-1]; if it has a sunspot on the left, when it is white, then flag [I] [J] = Flag [I-1] [J]; if it is black above and left, then flag [I] [J] = min (flag [I-1] [J], flag [I] [J]). then, we traverse qipan from right to left and from bottom to top. The principle is similar to above. When flag [I] [J] is 2, qipan [I] [J] = 0; // subquery.
Go subprogram:
It is obvious that the return method is used for analysis. When you move down, you can check the surrounding pawns associated with the pawns or when they are surrounded. (No need to traverse from scratch)
For example, the white sub is connected to two white sub, and the white sub is connected to four white sub... In this way, the system traverses the past. If it doesn't get through, it goes back to the system and continues the traversal. When the loop is formed, it eats the sunspots.
Java_web (continuously crawling up) algorithms are acceptable, but it is not considered that a person like fuzhu kills himself. You did not consider it. You only consider the situation when killing the other party.