fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <utility>
  7. #include <map>
  8. #include <set>
  9. #include <string>
  10. #include <cstring>
  11. #include <queue>
  12. #include <cassert>
  13. #define rf freopen("in.in", "r", stdin)
  14. #define wf freopen("out.out", "w", stdout)
  15. #define rep(i, s, n) for(int i=int(s); i<=int(n); ++i)
  16. using namespace std;
  17. const int mx = 1e5 + 10, mod = 1e9+7;
  18.  
  19. char tic[21][21];
  20.  
  21. int main()
  22. {
  23. //rf;// wf;
  24. ios::sync_with_stdio(0);
  25.  
  26. int t;
  27. cin >> t;
  28. assert(1 <= t and t <= 100);
  29.  
  30. while(t--)
  31. {
  32. int n, k;
  33. cin >> n >> k;
  34. assert(1 <=n and n<=20 and 1<=k and k<=n);
  35.  
  36. rep(i, 0, n-1)
  37. cin >> tic[i];
  38.  
  39. int check = 0;
  40. rep(i, 0, n-1)
  41. {
  42. rep(j, 0, n-1)
  43. {
  44. int markr = 0, markc = 0, markd1 = 0, markd2 = 0;
  45. int lenr = 0, lenc = 0, lend1 = 0, lend2 = 0;
  46. int ti = i, tj = j, tk = i;
  47.  
  48. rep(p, 0, k-1)
  49. {
  50. if(ti < n and markr <= 1)
  51. {
  52. if(tic[ti][j] == 'X')
  53. lenr++;
  54. if(tic[ti][j] == '.' and !markr)
  55. lenr++, markr++;
  56. }
  57. if(tj < n and markc <= 1)
  58. {
  59. if(tic[i][tj] == 'X')
  60. lenc++;
  61. if(tic[i][tj] == '.' and !markc)
  62. lenc++, markc++;
  63. }
  64. if(ti < n and tj < n and markd1 <= 1)
  65. {
  66. if(tic[ti][tj] == 'X')
  67. lend1++;
  68. if(tic[ti][tj] == '.' and !markd1)
  69. lend1++, markd1++;
  70. }
  71. if(tk >= 0 and tj < n and markd2 <= 1)
  72. {
  73. if(tic[tk][tj] == 'X')
  74. lend2++;
  75. if(tic[tk][tj] == '.' and !markd2)
  76. lend2++, markd2++;
  77. }
  78.  
  79.  
  80. ti++; tj++; tk--;
  81. }
  82.  
  83. if(lend1 == k or lend2 == k or lenc == k or lenr == k)
  84. {
  85. cout << "YES\n";
  86. check = 1;
  87. break;
  88. }
  89. }
  90.  
  91. if(check)
  92. break;
  93. }
  94.  
  95. if(!check)
  96. cout << "NO\n";
  97. }
  98. return 0;
  99. }
  100.  
Runtime error #stdin #stdout #stderr 0s 3456KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog: prog.cpp:28: int main(): Assertion `1 <= t and t <= 100' failed.