1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int xwin[8]; int owin[8]; /* 1 XX. XX. OOO */ string str[4]; bool rowcheck(char c) { for(int i=0;i<3;i++) { if(str[i][0]==str[i][1] && str[i][0]==str[i][2] && str[i][0]==c) return 1; } return 0; } bool diagncheck(char c) { if(str[0][0]==str[1][1] && str[1][1]==str[2][2] && str[1][1]==c) return 1; if(str[0][2]==str[1][1] && str[1][1]==str[2][0] && str[1][1]==c) return 1; return 0; } bool columncheck(char c) { for(int i=0;i<3;i++) { if(str[0][i]==c && str[0][i]==str[1][i] && str[0][i]==str[2][i]) return 1; } return 0; } int main() { int n,x=0,o=0; string s; scanf("%d",&n); getchar(); while(n--) { x = 0; o = 0; for(int cnt=0;cnt<3;cnt++) { getline(cin,s); str[cnt]=s; for(int i=0;i<3;i++) { if(str[cnt][i]=='O') o+=1; if(str[cnt][i]=='X') x+=1; } } if(!(x==o+1) && !(x==o)) printf("no\n"); else { bool r1,r2,c2,c1,d1,d2; r1 = rowcheck('O'); r2 = rowcheck('X'); c1 = columncheck('O'); c2 = columncheck('X'); d1 = diagncheck('O'); d2 = diagncheck('X'); //cout<<r2<<" "<<c2<<" "<<d2<<"\n"; //cout<<(r2||c2||d2)<<"\n"; if((r2||c2||d2) == 1 && (r1||c1||d1) == 1) printf("no\n"); else if( (r2||c2||d2) == 1 && !(x==o+1)) printf("no\n"); else if( (r1||c1||d1) == 1 && (x!=o)) printf("no\n"); else printf("yes\n"); } if(n) getline(cin,s); } return 0; } |