problem Descriptionyu Zhou likes to play Go with Su Lu. From the historical, we found this there is much difference on the rules between ancient go and modern go. here isThe rules forancient Go They were playing:⋅the game isPlayed on a8X8Cell board, the chess can be put in the intersection of the board lines, so there is9X9different positions to put the Chess.⋅yu Zhou always takes the black and Su Lu the white. They put the chess onto the game board alternately.⋅the chess of the same color makes connected components (connected by th E board lines), forEach of the components,ifIt's not connected with any of the empty cells, this component dies and would be a removed from the game board.⋅when one of the player makes his move, check the opponent's components first. After removing the dead opponent's components, check with the player's components and remove the dead components.One day, Yu Zhou is playing ancient go with Su Lu at home. It's Yu Zhou's move now. But they had to go forAn emergency military action. Little Qiao looked at the game board and would like to know whether Yu Zhou have a move to kill at least one of Su Lu's chess.Inputthe first line of the input gives the number of test cases, T (1≤t≤ -). T test Cases follow. Test cases is separated by a empty line. Each test Caseconsist of9Lines represent the game board. Each line consists of9characters. Each character represents a cell on the game board. ′.′represents an empty cell. ′x′represents a cell with black chess which owned by Yu Zhou. ′o′represents a cell with the white chess which owned by Su Lu. Outputfor each test Case, output one line containing case #x: Y,whereX isThe test CaseNumber (starting from 1) and Y isCan KillinchOne move!!!ifYu Zhou have a move to kill at least one of Su Lu's components. Can not kill in one move!!! otherwise.Sample Input2..... xo....................x.......xox....x.o.o ... Xo.. o...........xxxo....xooo.......ox........o....o.......o.o.......o.....................o....x.............o Sample Outputcase #1: Can KillinchOne move!!!Case #2: Can not KillinchOne move!!!Hintin the first Test Case, Yu Zhou has4Different ways to kill Su Lu's component.In the second Test Case, there isNo-to-kill Su Lu's component.
Put a black chess x can surround white o, only a black chess
Method Search White There are a few blank points around if it's less than or equal to 1.
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<stack>#include<queue>#include<vector>using namespacestd;#defineN 200#defineMet (A, b) memset (A,b,sizeof (a));Vector<vector<int> >Q;CharStr[n][n];intdis[4][2]= {{0,1},{1,0},{-1,0},{0,-1}};intVis[n][n];intPanintXinty) { return(x>=0&& x<9&& y>=0&& y<9);}intDfsintXinty) {vis[x][y]=1;intf=0; for(intI=0; i<4; i++) { intxx = x+dis[i][0]; intyy = y+dis[i][1]; if(Vis[xx][yy] | |!pan (XX,YY))///The searched and the cushion does not conform to skip Continue; if(str[xx][yy]=='.')///there is an accumulation{f++; VIS[XX][YY]=1; } if(str[xx][yy]=='o')///The number of blank points around the white gamef+=DFS (XX,YY); } returnF;}intSove () { for(intI=0; i<9; i++) { for(intj=0; j<9; J + +) { if(str[i][j]=='o')///Find a white search{met (Vis,0); intans=DFS (I,J); if(ans<=1) return 1; } } } return 0;}intMain () {intt,con=1; scanf ("%d",&t); while(t--) { for(intI=0; i<9; i++) scanf ("%s", Str[i]); intans=Sove (); if(ANS) printf ("Case #%d:can kill in one move!!! \ n", con++); Elseprintf ("Case #%d:can isn't kill in one move!!! \ n", con++); } return 0;}
(HDU) 5546 Ancient Go