fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define endl '\n'
  4. #define test int _; cin >> _; while (_--)
  5. #define mod 1000000007
  6. #define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  7.  
  8. using namespace std;
  9.  
  10. int a[10][10];
  11. pair<int,int> up(int ii, int jj){
  12. int x=0,space=0;
  13. for(int i=ii-1;i>=0;i--){
  14. if(a[i][jj] == 'X') x++;
  15. else{
  16. if(a[i][jj] == '.') space++;
  17. break;
  18. }
  19. }
  20. return {x,space};
  21. }
  22. pair<int,int> down(int ii, int jj){
  23. int x=0,space=0;
  24. for(int i=ii+1;i<10;i++){
  25. if(a[i][jj] == 'X') x++;
  26. else{
  27. if(a[i][jj] == '.') space++;
  28. break;
  29. }
  30. }
  31. return {x,space};
  32. }
  33. pair<int,int> left(int ii, int jj){
  34. int x=0,space=0;
  35. for(int j=jj-1;j>=0;j--){
  36. if(a[ii][j] == 'X') x++;
  37. else{
  38. if(a[ii][j] == '.') space++;
  39. break;
  40. }
  41. }
  42. return {x,space};
  43. }
  44. pair<int,int> right(int ii, int jj){
  45. int x=0,space=0;
  46. for(int j=jj+1;j<10;j++){
  47. if(a[ii][j] == 'X') x++;
  48. else{
  49. if(a[ii][j] == '.') space++;
  50. break;
  51. }
  52. }
  53. return {x,space};
  54. }
  55. pair<int,int> upright(int ii, int jj){
  56. int x=0,space=0;
  57. int i=ii-1,j=jj+1;
  58. while(i>=0 && j<10){
  59. if(a[i][j] == 'X') x++;
  60. else{
  61. if(a[i][j] == '.') space++;
  62. break;
  63. }
  64. i--;
  65. j++;
  66. }
  67. return {x,space};
  68. }
  69. pair<int,int> upleft(int ii, int jj){
  70. int x=0,space=0;
  71. int i=ii-1,j=jj-1;
  72. while(i>=0 && j>=0){
  73. if(a[i][j] == 'X') x++;
  74. else{
  75. if(a[i][j] == '.') space++;
  76. break;
  77. }
  78. i--;
  79. j--;
  80. }
  81. return {x,space};
  82. }
  83. pair<int,int> downright(int ii, int jj){
  84. int x=0,space=0;
  85. int i=ii+1,j=jj+1;
  86. while(i<10 && j<10){
  87. if(a[i][j] == 'X') x++;
  88. else{
  89. if(a[i][j] == '.') space++;
  90. break;
  91. }
  92. i++;
  93. j++;
  94. }
  95. return {x,space};
  96. }
  97. pair<int,int> downleft(int ii, int jj){
  98. int x=0,space=0;
  99. int i=ii+1,j=jj-1;
  100. while(i<10 && j>=0){
  101. if(a[i][j] == 'X') x++;
  102. else{
  103. if(a[i][j] == '.') space++;
  104. break;
  105. }
  106. i++;
  107. j--;
  108. }
  109. return {x,space};
  110. }
  111.  
  112. signed main() {
  113. fast
  114. for(int i=0;i<10;i++){
  115. for(int j=0;j<10;j++){
  116. cin>>a[i][j];
  117. }
  118. }
  119. for(int i=0;i<10;i++){
  120. for(int j=0;j<10;j++){
  121. if(a[i][j] == 'O') continue;
  122. auto u = up(i,j);
  123. auto d = down(i,j);
  124. auto l = left(i,j);
  125. auto r = right(i,j);
  126. auto ur = upright(i,j);
  127. auto ul = upleft(i,j);
  128. auto dr = downright(i,j);
  129. auto dl = downleft(i,j);
  130. if(a[i][j]=='X'){
  131. if((u.first+d.first >= 3 && u.second+d.second == 1) || (u.first+d.first >= 4)){
  132. cout<<"YES";
  133. return 0;
  134. }
  135. else if((l.first+r.first >= 3 && l.second+r.second == 1) || (l.first+r.first >= 4)){
  136. cout<<"YES";
  137. return 0;
  138. }
  139. else if((ul.first+dr.first >= 3 && ul.second+dr.second == 1) || (ul.first+dr.first >= 4)){
  140. cout<<"YES";
  141. return 0;
  142. }
  143. else if((dl.first+ur.first >= 3 && dl.second+ur.second == 1) || (dl.first+ur.first >= 4)){
  144. cout<<"YES";
  145. return 0;
  146. }
  147. }
  148. else {
  149. if (u.first + d.first >= 4) {
  150. cout << "YES";
  151. return 0;
  152. } else if (l.first + r.first >= 4) {
  153. cout << "YES";
  154. return 0;
  155. } else if (ul.first + dr.first >= 4) {
  156. cout << "YES";
  157. return 0;
  158. } else if (dl.first + ur.first >= 4) {
  159. cout << "YES";
  160. return 0;
  161. }
  162. }
  163. }
  164. }
  165. }
Success #stdin #stdout 0s 5284KB
stdin
XX.XX.....
.....OOOO.
..........
..........
..........
..........
..........
..........
..........
..........
stdout
Standard output is empty