/* The minimum path of poj 3020 overwrites the question and does not understand the idea at the beginning. Refer to the online code, this is the problem of least path coverage. O indicates that the antenna does not need to be overwritten. * It indicates that the antenna needs to be overwritten. One antenna can benefit two adjacent * points, ask the minimum number of antennas required to cover all * points with the minimum path overwrite of the undirected bipartite graph = point-Max match/2 modeling process: view each * point as a point, split points */# include <cstdio> # include <cstring> using namespace STD; # define maxn 405int t; int H, W; int count; int dir [4] [2] = {0, 1, 0,-1, 0,-1}; int map [41] [11]; int link [maxn] [maxn]; bool vis [maxn]; int match [maxn]; bool find (int x) {for (INT I = 1; I <= count-1; I ++) {If (! Vis [I] & link [x] [I]) {vis [I] = 1; if (find (Match [I]) | match [I] = 0) {match [I] = x; return true ;}}return false;} int MMG () {int ans = 0; memset (match, 0, sizeof (MATCH); For (INT I = 1; I <= count-1; I ++) {memset (VIS, 0, sizeof (VIS); If (find (I) ans ++;} return ans;} int main () {scanf ("% d", & T ); while (t --) {scanf ("% d", & H, & W); memset (MAP, 0, sizeof (MAP); memset (link, 0, sizeof (Link); char C [maxn]; Count = 1; For (INT I = 1; I <= H; I ++) {scanf ("% s", c); For (Int J = 1; j <= W; j ++) C [J-1] = '*'? Map [I] [J] = count ++: 0;} // For (INT I = 1; I <= H; I ++) // {// For (Int J = 1; j <= W; j ++) // printf ("% d", map [I] [J]); // printf ("\ n"); // while (1) {}for (INT I = 1; I <= H; I ++) for (Int J = 1; j <= W; j ++) {If (Map [I] [J]) {for (int K = 0; k <4; k ++) {int x = I + dir [k] [0], y = J + dir [k] [1]; If (Map [x] [Y]) link [map [I] [J] [map [x] [Y] = 1 ;}} int ans = MMG (); printf ("% d \ n", Count-1-(ANS/2 ));}}