Enhanced version 3041
Because the lawn cannot be covered by wooden boards, you need to deal with it more.
Since the wooden boards can only be placed horizontally or vertically, the first time the numbers of boards that can be placed horizontally and are not consecutive, and the second time the numbers of boards that can be placed vertically and are not consecutive
Think of a wooden board as a vertex and a muddy ground as an edge. A mud point corresponds to an edge, which is converted into a bipartite graph. The smallest vertex can be overwritten by all edges. The minimum vertex overwrites = the maximum number of matches.
Code:
# Include <iostream> using namespace STD; # define Max 1005 int link [Max], U [Max], W [Max] [Max], a [Max] [Max], B [Max] [Max]; char map [55] [55]; int NX, NY; int DFS (INT t) {for (INT I = 1; I <= NY; I ++) {If (! U [I] & W [T] [I]) {u [I] = 1; if (link [I] =-1 | DFS (link [I]) {link [I] = T; return 1 ;}} return 0 ;} int Hungary () {int I, num = 0; memset (link,-1, sizeof (Link); for (I = 1; I <= NX; I ++) {memset (u, 0, sizeof (u); num + = DFS (I);} return num;} int main () {int R, C, I, J; nx = ny = 0; scanf ("% d", & R, & C); getchar (); for (I = 1; I <= R; I ++) {for (j = 1; j <= C; j ++) {scanf ("% C", & map [I] [J]);} getchar () ;}for (I = 1; I <= r; I ++) {for (j = 1; j <= C; j ++) {If (Map [I] [J] = '*') {If (Map [I] [J-1] = '*') A [I] [J] = A [I] [J-1]; else a [I] [J] = + NX ;}} for (I = 1; I <= r; I ++) {for (j = 1; j <= C; j ++) {If (Map [I] [J] = '*') {If (Map [I-1] [J] = '*') B [I] [J] = B [I-1] [J]; else B [I] [J] = + + ny; W [A [I] [J] [B [I] [J] = 1 ;}} printf ("% d \ n", Hungary ()); return 0 ;}