题目传送门
1 /*
2 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2
3 */
4 #include <cstdio>
5 #include <algorithm>
6 #include <cstring>
7 using namespace std;
8
9 const int MAXN = 11;
10 const int INF = 0x3f3f3f3f;
11 char s[MAXN][MAXN];
12
13 int main(void) //Codeforces Round #212 (Div. 2) A. Two Semiknights Meet
14 {
15 int t; scanf ("%d", &t);
16 while (t--)
17 {
18 char ch; int x1, y1, x2, y2; bool ok = false;
19
20 for (int i=1; i<=8; ++i) scanf ("%s", s[i] + 1);
21 for (int i=1; i<=8; ++i)
22 {
23 for (int j=1; j<=8; ++j)
24 {
25 if (!ok && s[i][j] == 'K') {x1 = i; y1 = j; ok = true;}
26 if (ok && s[i][j] == 'K') {x2 = i; y2 = j;}
27 }
28 }
29
30 if ((x2 - x1) % 4 == 0 && (y2 - y1) % 4 == 0) puts ("YES");
31 else puts ("NO");
32 }
33
34 return 0;
35 }