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. char a[10][10];
  11. bool horizontal(){
  12. int res=0;
  13. for(int i=0;i<10;i++){
  14. int cnt=0;
  15. for(int j=0;j<10;j++){
  16. if(a[i][j]=='X') cnt++;
  17. else{
  18. res = max(res,cnt);
  19. cnt=0;
  20. }
  21. }
  22. res = max(res,cnt);
  23. }
  24. return res>=5;
  25. }
  26. bool vertical(){
  27. int res=0;
  28. for(int i=0;i<10;i++){
  29. int cnt=0;
  30. for(int j=0;j<10;j++){
  31. if(a[j][i]=='X') cnt++;
  32. else{
  33. res = max(res,cnt);
  34. cnt=0;
  35. }
  36. }
  37. res = max(res,cnt);
  38. }
  39. return res>=5;
  40. }
  41. bool diagonal(){
  42. int res=0;
  43. for (int row = 0; row < 10; row++) {
  44. int col = 0,cnt=0;
  45. while (row < 10 && col < 10) {
  46. if(a[row][col]=='X') cnt++;
  47. else{
  48. res = max(res,cnt);
  49. cnt=0;
  50. }
  51. row++;
  52. col++;
  53. }
  54. res = max(res,cnt);
  55. }
  56. for (int col = 1; col < 10; col++) {
  57. int row = 0,cnt=0;
  58. while (row < 10 && col < 10) {
  59. if(a[row][col]=='X') cnt++;
  60. else{
  61. res = max(res,cnt);
  62. cnt=0;
  63. }
  64. row++;
  65. col++;
  66. }
  67. res = max(res,cnt);
  68. }
  69.  
  70. for (int row = 0; row < 10; row++) {
  71. int col = 9,cnt=0;
  72. while (row < 10 && col >= 0) {
  73. if(a[row][col]=='X') cnt++;
  74. else{
  75. res = max(res,cnt);
  76. cnt=0;
  77. }
  78. row++;
  79. col--;
  80. }
  81. res = max(res,cnt);
  82. }
  83. for (int col = 8; col >= 0; col--) {
  84. int row = 0,cnt=0;
  85. while (row < 10 && col >= 0) {
  86. if(a[row][col]=='X') cnt++;
  87. else{
  88. res = max(res,cnt);
  89. cnt=0;
  90. }
  91. row++;
  92. col--;
  93. }
  94. res = max(res,cnt);
  95. }
  96. return res>=5;
  97. }
  98.  
  99. signed main() {
  100. fast
  101. for(int i=0;i<10;i++){
  102. for(int j=0;j<10;j++){
  103. cin>>a[i][j];
  104. }
  105. }
  106. bool f=0;
  107. for(int i=0;i<10;i++){
  108. for(int j=0;j<10;j++){
  109. if(a[i][j]=='.'){
  110. a[i][j] = 'X';
  111. if(vertical()||horizontal()||diagonal()){
  112. f=1;
  113. break;
  114. }
  115. a[i][j] = '.';
  116. }
  117. }
  118. if(f) break;
  119. }
  120. cout<< (f?"YES":"NO");
  121. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
NO