Advertisement
erfanul007

UVa 10363

Dec 8th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin>>t;
  9. while(t--){
  10. char g[5][5];
  11. cin>>g[1][1]>>g[1][2]>>g[1][3];
  12. cin>>g[2][1]>>g[2][2]>>g[2][3];
  13. cin>>g[3][1]>>g[3][2]>>g[3][3];
  14. int i,j,xcnt=0,ocnt=0,n;
  15. for(i=1;i<=3;i++){
  16. for(j=1;j<=3;j++){
  17. if(g[i][j]=='X')
  18. xcnt++;
  19. if(g[i][j]=='O')
  20. ocnt++;
  21. }
  22. }
  23. if(ocnt>xcnt){
  24. cout<<"no"<<endl;
  25. continue;
  26. }
  27. n=xcnt-ocnt;
  28. if(n>1){
  29. cout<<"no"<<endl;
  30. continue;
  31. }
  32. if(n==0){
  33. if(g[1][1]=='X'){
  34. if(g[1][2]=='X' && g[1][3]=='X'){
  35. cout<<"no"<<endl;
  36. continue;
  37. }
  38. if(g[2][1]=='X' && g[3][1]=='X'){
  39. cout<<"no"<<endl;
  40. continue;
  41. }
  42. if(g[2][2]=='X' && g[3][3]=='X'){
  43. cout<<"no"<<endl;
  44. continue;
  45. }
  46. }
  47. if(g[1][3]=='X'){
  48. if(g[2][3]=='X' && g[3][3]=='X'){
  49. cout<<"no"<<endl;
  50. continue;
  51. }
  52. if(g[2][2]=='X' && g[3][1]=='X'){
  53. cout<<"no"<<endl;
  54. continue;
  55. }
  56. }
  57. if(g[1][2]=='X'){
  58. if(g[2][2]=='X' && g[3][2]=='X'){
  59. cout<<"no"<<endl;
  60. continue;
  61. }
  62. }
  63. if(g[2][1]=='X'){
  64. if(g[2][2]=='X' && g[2][3]=='X'){
  65. cout<<"no"<<endl;
  66. continue;
  67. }
  68. }
  69. if(g[3][1]=='X'){
  70. if(g[3][2]=='X' && g[3][3]=='X'){
  71. cout<<"no"<<endl;
  72. continue;
  73. }
  74. }
  75. }
  76. if(n==1){
  77. if(g[1][1]=='O'){
  78. if(g[1][2]=='O' && g[1][3]=='O'){
  79. cout<<"no"<<endl;
  80. continue;
  81. }
  82. if(g[2][1]=='O' && g[3][1]=='O'){
  83. cout<<"no"<<endl;
  84. continue;
  85. }
  86. if(g[2][2]=='O' && g[3][3]=='O'){
  87. cout<<"no"<<endl;
  88. continue;
  89. }
  90. }
  91. if(g[1][3]=='O'){
  92. if(g[2][3]=='O' && g[3][3]=='O'){
  93. cout<<"no"<<endl;
  94. continue;
  95. }
  96. if(g[2][2]=='O' && g[3][1]=='O'){
  97. cout<<"no"<<endl;
  98. continue;
  99. }
  100. }
  101. if(g[1][2]=='O'){
  102. if(g[2][2]=='O' && g[3][2]=='O'){
  103. cout<<"no"<<endl;
  104. continue;
  105. }
  106. }
  107. if(g[2][1]=='O'){
  108. if(g[2][2]=='O' && g[2][3]=='O'){
  109. cout<<"no"<<endl;
  110. continue;
  111. }
  112. }
  113. if(g[3][1]=='O'){
  114. if(g[3][2]=='O' && g[3][3]=='O'){
  115. cout<<"no"<<endl;
  116. continue;
  117. }
  118. }
  119. }
  120. cout<<"yes"<<endl;
  121. }
  122. return 0;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement